KCNA Kubernetes Fundamentals Practice Question
Which of the following kubectl commands would you use to update a Deployment's image to 'nginx:1.21' and record the change in the rollout history?
⚠ Common exam trap
CNCF often tests the `--record` flag as a subtle requirement; candidates may pick option B because it correctly updates the image but forget that the question explicitly asks to record the change in the rollout history.
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/nginx nginx=nginx:1.21 --record
`kubectl set image deployment/nginx nginx=nginx:1.21 --record` updates the container image of the specified deployment and, with the `--record` flag, annotates the change in the rollout history (stored in the `kubernetes.io/change-cause` annotation). This allows you to later inspect the change with `kubectl rollout history deployment/nginx`.
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 nginx --image=nginx:1.21
Why it's wrong here
The --image flag is not valid with edit.
- ✗
kubectl set image deployment/nginx nginx=nginx:1.21
Why it's wrong here
This updates the image but does not record the change.
- ✓
kubectl set image deployment/nginx nginx=nginx:1.21 --record
Why this is correct
This updates the image and records the change in the rollout history.
- ✗
kubectl patch deployment nginx -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx","image":"nginx:1.21"}]}}}}' --record
Why it's wrong here
Using `kubectl patch` to update a Deployment's image, while technically feasible, is not the most direct or idiomatic approach, as it necessitates precise knowledge of the resource's JSON path to the image field. This command is tempting because it offers powerful capabilities for applying partial modifications to any resource, making it suitable for targeted changes like adding an annotation, adjusting a single environment variable, or modifying a specific field within a complex configuration when a dedicated `set` command is unavailable or a full resource replacement is undesirable.
Go deeper
Related to this question
About these practice questions
Courseiva writes every KCNA question from scratch — 833 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.