KCNA Kubernetes Fundamentals Practice Question
A Deployment named 'app-deploy' is configured with strategy type: RollingUpdate. You want to update the container image to a new version. What kubectl command should you use?
⚠ Common exam trap
A common mix-up: candidates think `kubectl apply` or `kubectl edit` are always the correct ways to update a deployment, but the exam tests the understanding that `kubectl set image` is the purpose-built command for updating container images in a deployment without needing a full manifest or interactive editing.
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/app-deploy app=new:tag
`kubectl set image` is the dedicated command for updating the container image of an existing deployment without modifying other fields. It directly modifies the deployment's pod template spec to use the new image, triggering a rolling update as defined by the deployment's strategy type.
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 apply -f updated-deployment.yaml
Why it's wrong here
Applying a manifest does update the image, but it replaces the whole declared spec rather than performing the imperative image update the question asks for; kubectl set image targets the container directly. apply is right when reconciling full YAML desired state from version control, not for a single targeted image change.
- ✗
kubectl edit deployment app-deploy
Why it's wrong here
kubectl edit opens the live object in an editor, bypassing the declarative manifest and risking drift from version control. It tempts because it does change the image, but the correct approach applies an updated manifest with kubectl apply, or uses kubectl set image for an imperative rollout.
- ✗
kubectl patch deployment app-deploy -p '{"spec":{"template":{"spec":{"containers":[{"name":"app","image":"new:tag"}]}}}}'
Why it's wrong here
This `kubectl patch` command directly modifies the Deployment's manifest, which can initiate a rollout. However, it is not the specific, idiomatic command designed for updating a container image within a Deployment, where the intention is to trigger a new revision and rolling update. `kubectl patch` is tempting because it can indeed alter any field, including the image, and is the correct choice for making granular, arbitrary modifications to fields without a dedicated `set` command, such as labels, annotations, or specific resource limits.
- ✓
kubectl set image deployment/app-deploy app=new:tag
Why this is correct
The kubectl set image command updates a Deployment's container image in place, triggering the configured RollingUpdate strategy to replace pods gradually. Targeting deployment/app-deploy with the container name and new tag satisfies the stem's requirement to roll out the new version without editing YAML manually.
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.