Courseiva
Container OrchestrationmediumMultiple ChoiceObjective-mapped

KCNA Container Orchestration Practice Question

A DevOps engineer wants to update a Deployment's container image from 'v1' to 'v2' with zero downtime. Which kubectl command should they use?

⚠ Common exam trap

Many exam-takers confuse `kubectl rollout restart` (which only restarts pods with the same image) with `kubectl set image` (which actually changes the image), or assume that any command modifying the Deployment (like patch or edit) inherently provides zero downtime without considering the rolling update mechanism.

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/<name> <container>=<image>:v2

`kubectl set image` directly updates the container image in a Deployment's pod template, triggering a rolling update that replaces pods incrementally with zero downtime. Kubernetes Deployments manage ReplicaSets to ensure availability during the update, making this the simplest and most reliable command for a controlled image change.

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 rollout restart deployment/<name>

    Why it's wrong here

    This restarts pods with the same image, not updating the image.

  • kubectl patch deployment <name> -p '{"spec":{"template":{"spec":{"containers":[{"name":"<container>","image":"<image>:v2"}]}}}}'

    Why it's wrong here

    This option is tempting because `kubectl patch` can indeed modify a Deployment's image, and for a Deployment configured with a `RollingUpdate` strategy, this change *will* trigger a zero-downtime rollout. However, it fails this scenario because `kubectl set image` is the dedicated, higher-level command specifically designed for updating container images within Deployments, StatefulSets, and other controllers. Using `kubectl set image` is the idiomatic and more robust approach for this operation, ensuring the rolling update mechanism is correctly engaged without needing to construct a complex JSON patch.

  • kubectl set image deployment/<name> <container>=<image>:v2

    Why this is correct

    This command triggers a rolling update, which by default updates pods gradually with zero downtime.

  • kubectl edit deployment <name>

    Why it's wrong here

    This opens an editor but does not guarantee zero downtime if the user makes incorrect changes.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on KCNA

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. You have a Deployment running 3 replicas. You need to update the container image without downtime. Which command updates the image while performing a rolling update?

medium
  • A.kubectl replace deployment my-deployment --image=nginx:1.25
  • B.kubectl set image deployment/my-deployment nginx=nginx:1.25
  • C.kubectl scale deployment my-deployment --image=nginx:1.25
  • D.kubectl update deployment my-deployment --image=nginx:1.25

Why B: `kubectl set image` triggers a rolling update on the Deployment, updating the container image gradually without downtime. Kubernetes automatically manages the rollout by creating new Pods with the new image and terminating old ones, ensuring the desired replica count is maintained throughout the process.

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.