kubectl rollout undo: Command Reference for CI/CD
Revert a bad deploy to the last known-good revision.
kubectl rollout undo reverts a Deployment to its previous revision, or to a specific one you name. It is the rollback half of a safe CI deploy. This reference covers undo, history, and the change-cause annotation that makes history readable.
Common flags and usage
- rollout undo deploy/<name>: revert to the previous revision
- --to-revision=N: revert to a specific revision number
- rollout history deploy/<name>: list revisions and change-causes
- rollout history --revision=N: show one revision in detail
- Annotate kubernetes.io/change-cause so history is meaningful
Example
shell
kubectl rollout history deploy/web
kubectl rollout undo deploy/web --to-revision=3
kubectl rollout status deploy/web --timeout=120sIn CI
Wire undo into the failure branch of your deploy gate so a rollout that misses its deadline auto-reverts. Set the change-cause annotation on each deploy (e.g. the commit SHA) so rollout history tells you exactly which revision to roll back to.
Key takeaways
- undo reverts to the previous revision; --to-revision targets a specific one.
- rollout history is only useful if you set change-cause annotations.
- Chain undo into the failure path of rollout status for auto-rollback.
Related guides
kubectl Cheat Sheet: Commands for Everyday KubernetesA kubectl cheat sheet - get, describe, logs, apply, rollout, debug, and context commands for daily Kubernetes…
kubectl rollout status: Command Reference for CI/CDReference for kubectl rollout status: block until a rollout completes and exit non-zero on failure, the canon…
kubectl rollout restart: Command Reference for CI/CDReference for kubectl rollout restart: trigger a fresh rolling restart with no spec change, to pick up a rota…
kubectl annotate: Command Reference for CI/CDReference for kubectl annotate: attach non-identifying metadata to resources, the change-cause annotation for…