KCNA Kubernetes Fundamentals Practice Question
You have a Deployment that manages 3 replicas of a web application. You want to perform a rolling update with zero downtime. Which kubectl command should you use?
⚠ Common exam trap
Watch out — candidates often confuse a simple pod deletion or scaling operation with a proper rolling update, or think that `rollout undo` is used to apply a new version instead of reverting to a previous one.
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/myapp mycontainer=myimage:v2
`kubectl set image deployment/myapp mycontainer=myimage:v2` triggers a rolling update on the Deployment, which by default creates a new ReplicaSet and gradually scales it up while scaling down the old ReplicaSet, ensuring zero downtime. The Deployment controller manages the update strategy (default: RollingUpdate) and maintains the desired number of replicas throughout the process.
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 set image deployment/myapp mycontainer=myimage:v2
Why this is correct
`kubectl set image` triggers the Deployment controller to create a new ReplicaSet and roll pods over incrementally, honouring maxUnavailable and maxSurge so capacity never drops to zero. This satisfies the stem's zero-downtime constraint, unlike editing a bare pod or scaling, which bypass the rolling-update mechanism entirely.
- ✗
kubectl delete pod myapp-xyz --grace-period=0
Why it's wrong here
Deleting a pod with a zero grace period terminates it immediately, causing downtime and bypassing the Deployment's rolling update strategy. It would be correct for force-removing a stuck pod. Zero-downtime rolling updates are triggered by changing the pod template, for example via kubectl set image.
- ✗
kubectl patch deployment myapp -p '{"spec":{"replicas":5}}'
Why it's wrong here
Patching replicas to five scales the Deployment horizontally; it does not change the pod template, so no rolling update occurs and existing pods keep running the old image. It would be correct for scaling capacity. A rolling update requires modifying the template, such as kubectl set image.
- ✗
kubectl rollout undo deployment/myapp
Why it's wrong here
This reverts a Deployment to its previous revision, so it cannot initiate the new rolling update the scenario requires. It is tempting because rollout undo is the correct tool for recovering from a failed update, but here the task is to trigger the update itself, which kubectl set image or apply performs.
Go deeper
Related to this question
About these practice questions
Courseiva writes every KCNA question from scratch — 930 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 KCNA 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 KCNA exam.