Question 22
Domain 2: Application Deployment and WorkloadsWhich kubectl action is used to update a container image in an existing Deployment?
Correct answer: A
Explanation
`kubectl set image` updates the image field on an existing workload without recreating it. For a Deployment, the syntax is `kubectl set image deployment/<name> <container>=<image>:<tag>`, which changes the specified container’s image in place and triggers a rollout.
Why each option is right or wrong
A. kubectl set image deployment/<name> <container>=<image>:<tag>
Under the Kubernetes `kubectl set` subcommand, `set image` patches the `spec.template.spec.containers[].image` field on an existing workload, which is the field the Deployment controller watches for rollout changes. The syntax is `kubectl set image deployment/<name> <container>=<image>:<tag>`, and because the Deployment’s pod template changes, Kubernetes creates a new ReplicaSet and rolls it out without deleting the Deployment object itself.
B. kubectl edit deployment/<name> --image=<image>:<tag>
C. kubectl rollout image deployment/<name> <container>=<image>:<tag>
D. kubectl patch image deployment/<name> <container>=<image>:<tag>