You pushed a new image to a Deployment and now you need to know whether the rollout finished, what changed, and how to get back to the last good version fast. The kubectl rollout subcommands do all four: status watches the update live and tells you when it succeeds or stalls, history shows you the revisions, pause/resume let you batch edits, and undo rolls back to the previous revision — or any revision you name. This guide walks through each one, and explains the Deployment revisions and ReplicaSets underneath so the commands stop feeling like magic.
What you’ll accomplish
- Watch a rolling update in progress and read its success or
progress deadline exceededsignal. - List a Deployment’s revision history and inspect exactly what a given revision changed.
- Pause a rollout to batch several changes into one release, then resume it.
- Roll back to the previous revision, or to a specific
--to-revision=N. - Understand how ReplicaSets,
revisionHistoryLimit, and the RollingUpdate strategy make all of this work.
Prerequisites
- A running Kubernetes cluster,
kubectl1.29 or newer (kubectl version). Therolloutsubcommands are stable and behave the same on older releases; only minor output formatting differs. - Permission to
get,patch,update, andapplyDeployments in your namespace, plusgeton ReplicaSets and Pods. - A Deployment you can safely update. Examples use a Deployment named
webin namespacedemo; substitute your own name and namespace. rolloutalso works on StatefulSets and DaemonSets. This guide focuses on Deployments, where the revision model is clearest.
How it works
A Deployment does not update Pods directly. It owns a series of ReplicaSets, one per template change, and each of those is a revision. When you change the Pod template — a new image, a changed env var, a different resource limit — the Deployment creates a new ReplicaSet and, following its .spec.strategy, scales the new one up while scaling the old one down. The old ReplicaSet is not deleted; it is scaled to zero and kept as history. That retained, scaled-to-zero ReplicaSet is exactly what a rollback reuses.
The default strategy is RollingUpdate, tuned by two fields. maxUnavailable caps how many Pods can be down at once during the swap; maxSurge caps how many extra Pods can be created above the desired count. With both at their 25% default, Kubernetes brings up new Pods before it removes old ones, which is what keeps the Service serving through the update. See rolling deploys without dropping requests for how that interacts with readiness gating.
Two more fields govern the edges. revisionHistoryLimit (default 10) is how many old ReplicaSets the Deployment keeps — set it too low and the revision you wanted to roll back to may already be pruned. progressDeadlineSeconds (default 600) is how long the Deployment waits for forward progress before it marks the rollout failed; that failure is what kubectl rollout status surfaces as exceeded its progress deadline. Rolling back does not rewind history — the rollback is applied as a new revision that happens to reuse an old ReplicaSet’s template, so the revision numbers always climb.
Step-by-step
1. Trigger an update and watch it. Change something in the template — here a new image — then watch the rollout. kubectl rollout status blocks until the update completes or the progress deadline is hit:
kubectl set image deployment/web web=web:1.1 -n demo
kubectl rollout status deployment/web -n demo
On success it prints each waiting state and then exits 0:
Waiting for deployment "web" rollout to finish: 1 out of 3 new replicas have been updated...
Waiting for deployment "web" rollout to finish: 2 out of 3 new replicas have been updated...
Waiting for deployment "web" rollout to finish: 1 old replicas are pending termination...
deployment "web" successfully rolled out
Because it exits non-zero on failure, rollout status is the right gate in a deploy script: if it returns an error, stop and roll back.
2. Record a change-cause so history is readable. The CHANGE-CAUSE column in history is populated from the kubectl.kubernetes.io/change-cause annotation. Set it on the same change you want it to describe:
kubectl annotate deployment/web -n demo \
kubectl.kubernetes.io/change-cause="update image to web:1.1" --overwrite
The older --record flag did the same thing automatically but is deprecated; annotate explicitly instead.
3. List the revision history. Each row is one retained ReplicaSet:
kubectl rollout history deployment/web -n demo
deployment.apps/web
REVISION CHANGE-CAUSE
1 initial deploy
2 update image to web:1.1
4. Inspect what a specific revision contains. Add --revision=N to see that revision’s Pod template — image, labels, env, resources — so you know what you would be rolling back to before you do it:
kubectl rollout history deployment/web -n demo --revision=1
deployment.apps/web with revision #1
Pod Template:
Labels: app=web
pod-template-hash=5f7c9d
Containers:
web:
Image: web:1.0
Port: 8080/TCP
5. Pause a rollout to batch changes. Pausing stops the Deployment from acting on template edits, so several changes land as one rollout instead of one each:
kubectl rollout pause deployment/web -n demo
kubectl set image deployment/web web=web:1.2 -n demo
kubectl set resources deployment/web -n demo --limits=cpu=500m,memory=256Mi
Nothing rolls out yet. Resume to apply all the edits together:
kubectl rollout resume deployment/web -n demo
deployment.apps/web resumed
6. Roll back to the previous revision. If the new release is bad, undo with no revision flag reverts to the immediately preceding revision:
kubectl rollout undo deployment/web -n demo
deployment.apps/web rolled back
Under the hood this scales the current (bad) ReplicaSet down and the previous ReplicaSet back up. No image is pulled fresh — the old ReplicaSet already describes the known-good template.
7. Roll back to a specific revision. When the previous revision is also suspect, name the one you trust with --to-revision:
kubectl rollout undo deployment/web -n demo --to-revision=1
deployment.apps/web rolled back
--to-revision=0 (the default when omitted) means “the previous revision.” Any other number targets that exact revision from rollout history.
Validate it works
Confirm the rollback completed. Run rollout status again — it should report success quickly, since the target ReplicaSet already exists:
kubectl rollout status deployment/web -n demo
deployment "web" successfully rolled out
Confirm the running image is the one you rolled back to.
kubectl get deployment web -n demo -o jsonpath='{.spec.template.spec.containers[0].image}'
web:1.0
Confirm the history moved forward, not backward. The rollback is a new revision at the top; the old numbers are not reused:
kubectl rollout history deployment/web -n demo
deployment.apps/web
REVISION CHANGE-CAUSE
2 update image to web:1.1
3 update image to web:1.2
4 update image to web:1.0
Revision 4 is the rollback. Revision 1’s template was reused, but it is recorded as a fresh revision.
Troubleshooting
- Rollout stuck on a bad image (
ImagePullBackOff).rollout statushangs, then afterprogressDeadlineSecondsprintserror: deployment "web" exceeded its progress deadline. Check the new Pods withkubectl get pods -n demoandkubectl describe pod— a typo’d tag or missing registry credential shows asImagePullBackOfforErrImagePull. Roll back withkubectl rollout undo; the old ReplicaSet is still healthy, so recovery is immediate. See debugging with kubectl for reading the Pod events. undodid nothing / “no rollout history found”. If the Deployment only has one revision, there is no previous ReplicaSet to return to andundohas nothing to do. This also happens right afterkubectl applyof a brand-new Deployment. Confirm withkubectl rollout history— you need at least two revisions beforeundois meaningful.CHANGE-CAUSEshows<none>. Thekubectl.kubernetes.io/change-causeannotation was never set for that revision. History still works — you can roll back by revision number — but the column is blank because nothing described the change. Annotate on every change going forward, or use--revision=Nto inspect the template directly instead of relying on the label.- The revision you wanted was pruned. If
--to-revision=Nreturnsunable to find specified revision,revisionHistoryLimitalready garbage-collected that ReplicaSet. The default keeps 10; a low value keeps fewer. You cannot recover a pruned revision — re-create the template from source. RaiserevisionHistoryLimitif you need a longer rollback window. - A rollback appears to change nothing. If the “bad” and “previous” revisions have identical Pod templates, Kubernetes treats the undo as a no-op and no new ReplicaSet is scaled. Confirm the templates actually differ with
kubectl rollout history --revision=Non both before assuming the rollback failed.
When this is the wrong approach
kubectl rollout undo reverts the Pod template a Deployment manages. It is not a general-purpose time machine.
- It does not roll back data. A schema migration, a mutated database, or a written-to volume is not reverted by scaling an old ReplicaSet back up. Rolling the app back to code that expects the old schema can make things worse. Plan data changes to be backward-compatible across a rollback.
- It does not revert non-template resources. ConfigMaps, Secrets, Services, and Ingress are separate objects. If your bad release also changed a ConfigMap,
undoon the Deployment leaves that ConfigMap changed. Track those in the same version control and revert them alongside. - It is manual recovery, not a release strategy. If you find yourself rolling back often, the fix is upstream: better readiness gating, canary or blue/green releases, and a CI gate on
rollout status.undois the break-glass, not the plan. - For non-Deployment workloads with their own semantics — a StatefulSet with ordered, persistent Pods — a rollback interacts with storage and ordering in ways a stateless Deployment does not. Read the workload’s own update behavior first, in Deployments and ReplicaSets and the official docs, before treating
undoas safe.
The authoritative references are the Kubernetes Deployment documentation, which specifies the revision and rollback behavior exactly, and the kubectl rollout command reference.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.