Courseiva
Application Deployment →mediumMultiple Choice

CKAD Application Deployment Practice Question

You want to update a Deployment's image from nginx:1.20 to nginx:1.21. Which command will perform a rolling update?

⚠ Common exam trap

Many candidates think `kubectl apply` or `kubectl edit` are the standard ways to trigger a rolling update, but the CKAD exam specifically tests the `kubectl set image` command as the direct imperative method for updating a Deployment's image.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

kubectl set image deployment/my-deployment nginx=nginx:1.21

`kubectl set image` directly updates the container image of a Deployment, which triggers a rolling update by default. The Deployment controller creates a new ReplicaSet with the updated image and gradually scales it up while scaling down the old ReplicaSet, ensuring zero downtime.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    kubectl create deployment my-deployment --image=nginx:1.21

    Why it's wrong here

    kubectl create deployment is an imperative command for creating a brand-new Deployment resource, not for updating an existing one. If a Deployment named my-deployment already exists, the API server will reject the create because the name is already taken, and even if it did not, it would spin up a separate object rather than change the running Deployment's image. Therefore the existing Deployment's pod template remains at nginx:1.20, so this does not accomplish the update.

  • ✗

    kubectl apply -f deployment.yaml

    Why it's wrong here

    kubectl apply -f deployment.yaml is a declarative operation that reconciles the live Deployment to the exact manifest in the file, but the file must already contain the updated image. If deployment.yaml still specifies nginx:1.20 or does not include an image field, kubectl apply will either leave the image unchanged or revert the running Deployment back to the version in the file. Without editing that manifest ahead of time, the update to nginx:1.21 never occurs.

  • ✓

    kubectl set image deployment/my-deployment nginx=nginx:1.21

    Why this is correct

    kubectl set image deployment/my-deployment nginx=nginx:1.21 is the correct imperative command because it directly changes the image of the container named nginx in the existing Deployment's pod template. The Deployment controller detects the template hash change, creates a new ReplicaSet, and performs a rolling update while keeping the Deployment name and metadata intact. This is a one-line, non-interactive, auditable update that accomplishes exactly the requested change.

  • ✗

    kubectl edit deployment my-deployment

    Why it's wrong here

    kubectl edit deployment my-deployment fetches the live Deployment object and opens it in your default editor, so it is an interactive workflow rather than a direct image-setting command. You can manually change the image and save, which does trigger a rolling update, but the command itself never sets the image; it only opens an editor for you to make the change. It is unsuitable for scripting or automation because it requires a human to edit YAML and write the file in an editor.

About these practice questions

One of 826 original CKAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKAD practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKAD exam.