Courseiva
Kubernetes FundamentalsmediumMultiple ChoiceObjective-mapped

KCNA Kubernetes Fundamentals Practice Question

You want to update a Deployment's container image to v2 and perform a rolling update using the simplest imperative command. Which kubectl command achieves this?

⚠ Common exam trap

A common pitfall is assuming that `kubectl update` is a valid command (it is not) or that `kubectl patch` is the simplest approach. While `kubectl patch` can update the image, it is not the simplest or most direct imperative command for this task.

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/my-deployment my-container=myapp:v2 --record

The `kubectl set image` command is the standard imperative way to update a container image in a Deployment, and it automatically triggers a rolling update. Option A is invalid; `kubectl update` is not a real command. Option B, `kubectl replace`, requires a full YAML file and is a declarative replacement operation, not a simple image update command. Option C, `kubectl patch`, can be used but is overly complex and error-prone for a simple image update. The question asks for the simplest imperative command, making D the best answer.

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 update deployment my-deployment --image=myapp:v2

    Why it's wrong here

    `kubectl update` is not a valid kubectl command. The correct imperative command for updating a resource is `kubectl set` or `kubectl edit`.

  • kubectl replace -f updated-deployment.yaml

    Why it's wrong here

    `kubectl replace -f updated-deployment.yaml` fails because it performs a full replacement of the existing Deployment object rather than initiating a rolling update; the rolling-update strategy is a property of the Deployment controller that `kubectl replace` does not trigger. It is tempting because `kubectl replace` is the correct command when you need to apply a complete, declarative configuration change from a file (e.g., after editing a YAML manifest offline), but it does not orchestrate the gradual pod replacement that a rolling update requires.

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

    Why it's wrong here

    `kubectl patch` is a generic command for applying partial updates to a resource, and while it will modify the Deployment's Pod template, thereby triggering a rolling update, it is not the most direct or idiomatic command for this specific task. This option is tempting because `kubectl patch` can indeed update an image and cause a rolling update. However, it is primarily intended for applying arbitrary, partial configuration changes to a resource, often when a more specific command does not exist, or for programmatic updates. For updating a container image, `kubectl set image` offers a more concise and purpose-built solution.

  • kubectl set image deployment/my-deployment my-container=myapp:v2 --record

    Why this is correct

    `kubectl set image` directly updates the container image for a specific container and initiates a rolling update; adding `--record` annotates the change for rollback history.

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

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.