Courseiva
Application Deployment →mediumMultiple Select

CKAD Application Deployment Practice Question

Which TWO commands can be used to update the image of a Deployment? (Select two)

⚠ Common exam trap

The CKAD exam often tests the distinction between valid imperative commands (`set image`, `edit`, `patch`) and invalid or misused commands (`update`, `replace` with wrong flags), so candidates must remember that `kubectl update` does not exist and `kubectl replace` requires a full manifest, not a flag-based update.

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 app=nginx:1.21

Options A and D are correct because `kubectl set image` directly updates the container image, and `kubectl patch` modifies the Deployment manifest using a JSON patch. Option B is incorrect because `kubectl edit` only opens the manifest in an editor, requiring manual changes; it does not directly update the image. Option C is incorrect because `kubectl update` is not a valid command. Option E is incorrect because `kubectl replace` requires a full manifest file, not just an image flag.

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 app=nginx:1.21

    Why this is correct

    This command is correct because it imperatively modifies the container's image using the syntax `deployment/<name> <container>`=`<new-image>`. It directly patches the live Deployment object and triggers a rollout if the pod template changes. It is the most concise and readable way to update an image for a single Deployment, which is why it is commonly used in CI/CD pipelines.

  • ✗

    kubectl edit deployment myapp

    Why it's wrong here

    The `edit` command does not itself change the image; it fetches the current Deployment manifest and opens it in the default text editor for manual modification. You must locate the container's `image` field, type in the new value, and save the file before any update occurs. As a result, `kubectl edit` is an interactive workflow rather than a direct, single-command image update, and it is also error-prone if the manifest is edited incorrectly.

  • ✗

    kubectl update deployment myapp --image=nginx:1.21

    Why it's wrong here

    `kubectl update` is not a valid kubectl verb; the kubectl CLI has a fixed set of imperative commands such as `set`, `patch`, `edit`, and `apply`. Because the command name is unrecognized, kubectl returns an error before any request is sent to the API server, so this cannot update the Deployment image. Use `kubectl set image` or `kubectl patch` instead.

  • ✓

    kubectl patch deployment myapp -p '{"spec":{"template":{"spec":{"containers":[{"name":"app","image":"nginx:1.21"}]}}}}'

    Why this is correct

    This patch command is correct because it issues a strategic merge patch that directly updates the named container's image inside the pod template. It is non-interactive and scriptable, making it suitable for automated rollouts. Note that the container name `app` must exist in the Deployment, otherwise the Kubernetes API rejects the patch with a validation error.

  • ✗

    kubectl replace deployment myapp --image=nginx:1.21

    Why it's wrong here

    `kubectl replace` expects a full resource manifest in YAML or JSON, usually from a file or stdin, and it substitutes the entire object with that new definition; it does not accept an `--image` flag. Since no manifest is provided, kubectl would fail immediately for lack of input, and even with a manifest, it would not selectively alter a single field but would overwrite the whole Deployment.

About these practice questions

Courseiva writes every CKAD question from scratch — 826 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 CKAD 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 CKAD exam.