Skip to content
Latchkey

kubectl rollout undo: Usage, Options & Common CI Errors

Roll a bad deploy back to a known-good revision in one command.

kubectl rollout undo reverts a controller to its prior revision, or to a revision you name. It is the canonical recovery step a CI pipeline runs when rollout status reports a failed deploy.

What it does

kubectl rollout undo deploy/NAME re-applies the previous revision's pod template, which triggers a fresh rollout back to that state. --to-revision=N targets a specific revision from rollout history; --to-revision=0 (the default) means the immediately previous one.

Common usage

Terminal
kubectl rollout undo deploy/web
kubectl rollout undo deploy/web --to-revision=3
kubectl rollout status deploy/web --timeout=120s   # gate the rollback too

Common errors in CI

"error: no rollout history found for deployment \"web\"" or a no-op undo happens when only one revision exists - there is nothing to roll back to, common on a brand-new Deployment that failed its very first rollout. In that case there is no good state to return to; fix forward instead. After an undo, always run kubectl rollout status to confirm the rollback itself succeeded - undo can fail for the same reason the original deploy did (bad probe, missing image). Note undo rolls back the pod template, not external state like a database migration the bad release already ran.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →