CKAD Application Deployment Practice Question
You have a Deployment named 'web-app' with 5 replicas. You run 'kubectl set image deployment/web-app app=nginx:1.21'. What is the effect of this command?
⚠ Common exam trap
Watch out — candidates often confuse `kubectl set image` with `kubectl delete pod` or assume it immediately terminates all pods, but it actually triggers a controlled rolling update that replaces pods gradually.
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
✓
It updates the image of the container named 'app' to nginx:1.21, triggering a rolling update.
The `kubectl set image` command updates the container image in the Deployment's pod template. This triggers a rolling update, where the Deployment's ReplicaSet creates new pods with the new image and gradually terminates old pods, ensuring zero downtime. The container name 'app' matches the container in the pod spec, so the image is updated to nginx:1.21.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
It scales the Deployment to 0 replicas and then scales back up.
Why it's wrong here
This option misreads the scope of kubectl set image: it only mutates the container image field inside the Deployment's pod template, never the replicas field. Your Deployment still has 5 replicas before, during, and after the command, so no scale-to-zero and scale-back-up cycle occurs. The ReplicaSet controller maintains the desired replica count throughout the update, and the rolling update moves traffic to new pods without ever dropping below the configured minimum availability.
- ✗
It immediately terminates all running pods and creates new ones with the new image.
Why it's wrong here
This describes a Recreate strategy, but the Deployment's default strategy is RollingUpdate, which is what kubectl set image triggers by default. Instead of terminating all pods at once, the Deployment controller creates a new ReplicaSet with the updated image and gradually scales it up while scaling down the old ReplicaSet, respecting maxUnavailable and maxSurge. Pod termination and creation happen incrementally, not immediately for all running pods, so existing services remain available during the transition.
- ✗
It creates a new Deployment with the updated image.
Why it's wrong here
kubectl set image is an imperative command that modifies an existing Deployment object; it never creates a new Deployment resource. The Deployment named 'web' is located, and its spec.template.spec.containers entry for the container called 'app' is updated in place. While this change causes new ReplicaSets and pods to be created, the Deployment's name, metadata, labels, selector, and replica count all remain the same—only the pod template's image field changes.
- ✓
It updates the image of the container named 'app' to nginx:1.21, triggering a rolling update.
Why this is correct
The command kubectl set image deployment/web app=nginx:1.21 targets the existing Deployment and updates the image of the container literally named 'app' in its pod template. This change to the pod template makes the Deployment controller detect a diff and begin a rolling update: it creates a new ReplicaSet with the nginx:1.21 image and progressively replaces old pods, preserving availability according to the rollout strategy. You can watch progress with kubectl rollout status deployment/web, and if needed, the update can be rolled back with kubectl rollout undo.
Go deeper
Related to this question
About these practice questions
This CKAD question is part of Courseiva's 826-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.