How do you roll back a bad release and verify you are back on the previous version?
BeginnerScenarioDeployments and rollouts
Answer
Situation read → Production is showing errors right after a deploy and you need the last known-good version now.
What I'd do →
kubectl rollout history deploy/webto see revisionskubectl rollout undo deploy/web(or--to-revision=3)kubectl rollout status deploy/webkubectl get deploy web -o jsonpath='{.spec.template.spec.containers[0].image}'to confirm the image- Annotate the revision with the reason using
kubectl annotate deploy/web kubernetes.io/change-cause="rollback to v1.4.2"
Why → Rollback re-applies the pod template of an older ReplicaSet, so it is fast and uses the same rolling strategy. Only the pod template is rolled back, not replicas or other fields.
Interview tip → Mention revisionHistoryLimit: if it is 0 there is nothing to roll back to.
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?BeginnerAfter a deploy, pods are Ready but users get 502s for a few seconds. What is happening and how do you fix it?Intermediate