CKAD Application Deployment Practice Question
You need to perform a rolling update of a Deployment named 'web-app' with a new image version. Which command should you use?
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/web-app app=nginx:1.21
The 'kubectl set image' command is used to update the container image of a Deployment, triggering a rolling update. In this case, 'kubectl set image deployment/web-app app=nginx:1.21' updates the container named 'app' to the new image version. Options A, B, and D are incorrect: A requires editing the manifest interactively, B replaces the entire resource definition, and D restarts pods without changing the image.
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 edit deployment web-app
Why it's wrong here
kubectl edit opens the live Deployment object in your default editor; while you can manually change the image to nginx:1.21 and save, this is an interactive multi-step process rather than a single, repeatable, scriptable command. Editing also sends a strategic merge patch of the entire object, so it's easy to accidentally introduce whitespace or structural errors. It can work, but it is not the direct, imperative image-update command the task asks for.
- ✗
kubectl replace -f web-app.yaml
Why it's wrong here
kubectl replace -f web-app.yaml takes a complete YAML/JSON manifest and submits it to the API server, replacing the entire Deployment object, not just the container image. If the manifest's resourceVersion is stale, the API rejects the replacement, and if other fields differ, they get overwritten. The command is intended for full object updates from a known file, not for surgically changing a single container image.
- ✓
kubectl set image deployment/web-app app=nginx:1.21
Why this is correct
kubectl set image deployment/web-app app=nginx:1.21 changes the container named app in the Deployment web-app to use the nginx:1.21 image, directly altering the pod template of the Deployment. This triggers a rolling update by creating a new ReplicaSet and scaling it up while scaling down the old one, honoring maxSurge and maxUnavailable. It is the concise, imperative command explicitly designed for this image-update operation.
- ✗
kubectl rollout restart deployment/web-app
Why it's wrong here
kubectl rollout restart deployment/web-app adds a pod-template annotation to force the Deployment to create a new ReplicaSet and replace all pods without changing the pod spec's image. Restarted pods will still run the original image (e.g., nginx:1.20), so this does not achieve the required update to nginx:1.21. It is useful for re-pulling an image or re-reading ConfigMaps, but it is not an image update.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CKAD question from scratch — 826 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.