Courseiva
Ensuring Successful Operation of a Cloud SolutionmediumMultiple ChoiceObjective-mapped

Google ACE Practice Question: Ensuring Successful Operation of a Cloud Solution

You notice that a deployment in your GKE cluster is running an outdated image. You need to update the deployment to use the new image 'gcr.io/my-project/my-app:v2'. Which kubectl command should you use?

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-app=gcr.io/my-project/my-app:v2

To update the image of a deployment, use 'kubectl set image' specifying the deployment name and the container name:tag.

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/my-deployment my-app=gcr.io/my-project/my-app:v2

    Why this is correct

    kubectl set image deployment/my-deployment my-app=gcr.io/my-project/my-app:v2 is the correct imperative command to update a container image inside a Deployment. The container name (my-app) must exactly match the container name defined in the Deployment's pod spec, and the command updates the pod template so the Deployment controller creates a new ReplicaSet and performs a rolling update. This is the canonical kubectl syntax for changing an image without editing a manifest.

  • kubectl rollout restart deployment my-deployment --image gcr.io/my-project/my-app:v2

    Why it's wrong here

    kubectl rollout restart deployment my-deployment --image gcr.io/my-project/my-app:v2 is invalid and conceptually wrong: the rollout restart subcommand does not support an --image flag, and even without that flag it would only add an annotation to trigger a new ReplicaSet using the existing pod template image. It is useful for restarting pods to re-pull the same image or re-read ConfigMaps, but it cannot change the container image to v2. Use kubectl set image to actually update the image.

  • kubectl update deployment my-deployment --image gcr.io/my-project/my-app:v2

    Why it's wrong here

    kubectl update deployment my-deployment --image gcr.io/my-project/my-app:v2 is incorrect because kubectl update is not a valid subcommand; kubectl uses edit, apply, patch, replace, and set to modify resources. This command would fail with an unknown command error, and even if a hypothetical update subcommand existed, the --image flag is not part of its syntax. The correct imperative image update is kubectl set image deployment/my-deployment my-app=<new-image>.

  • kubectl replace deployment my-deployment --image gcr.io/my-project/my-app:v2

    Why it's wrong here

    kubectl replace deployment my-deployment --image gcr.io/my-project/my-app:v2 is wrong because kubectl replace requires a YAML/JSON manifest file passed with -f and does not accept an --image flag; it overwrites the entire existing resource definition with the specified file contents. This command would fail with an unknown flag error and would not perform an incremental image update. A proper kubectl replace -f deployments.yaml would require the file to already contain the new image, making it a declarative replacement, not a simple image update.

About these practice questions

One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 ACE practice question is part of Courseiva's free Google Cloud 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 ACE exam.