How do you update an image in a running Deployment without modifying the manifest?
- kubectl set image deployment/my-app app=nginx:1.19 ✓
- kubectl rollout restart deployment/my-app
- kubectl patch deployment my-app --image=nginx:1.19
- kubectl edit deployment my-app
Correct answer: kubectl set image deployment/my-app app=nginx:1.19
The command 'kubectl set image deployment/my-app app=nginx:1.19' directly updates the container image for the named container within the Deployment object via the API server without requiring the user to open or edit the manifest file, and Kubernetes will perform a rolling update automatically. Option B is incorrect because 'kubectl rollout restart' triggers a rolling restart of the pods using the existing image, not an image update; it does not change which image version is used. Option C is incorrect because 'kubectl patch' with '--image' is not valid syntax; while kubectl patch can update a Deployment, it requires a JSON or strategic merge patch payload specifying the full container spec path, not a simple --image flag. Option D is incorrect because 'kubectl edit' opens the live manifest in a text editor for interactive modification, which does modify the manifest (the live resource definition) and is the opposite of updating without touching the manifest.
Topic: · kubectl, deployment, image update, rolling update