GCP Associate Cloud Engineer Practice Question 26: kubectl Rollout Undo
Google Cloud Associate Cloud Engineer · Test 3 · question 6 of 10
You updated the container image of the Deployment web with kubectl set image. The new pods crash on startup and users see errors. You need to return to the previous working version as quickly as possible.
Which command should you run?
Show answer and explanation
Answer:
Every change to a Deployment's pod template creates a new revision. kubectl rollout undo deployment/web rolls back to the previous revision (or to a specific one with --to-revision), replacing the crashing pods with pods that use the earlier image.
kubectl rollout restart recreates the pods with the current template, so they would keep crashing. Scaling to zero stops the service completely, so it does not fix the problem. kubectl rollout pause suspends further updates but leaves the bad revision running.
Reference: Rolling back a Deployment