Skip to content
Latchkey

kubectl rollout undo: Roll Back Deploys in CI

Revert a workload to its previous revision (or a specific one).

kubectl rollout undo rolls a Deployment back to an earlier revision from its rollout history. In CI it is the automated rescue step: if the post-deploy smoke test fails, undo to the last good revision. History depth is bounded by revisionHistoryLimit.

Common flags

  • RESOURCE/NAME - e.g. deployment/api (positional)
  • -n NAMESPACE - target namespace
  • --to-revision=N - roll back to a specific revision (0 = previous)

Example in CI

Undo to the previous revision when a smoke test fails.

shell
kubectl rollout undo deployment/api -n prod

Common errors in CI

  • error: no rollout history found ... - only one revision exists
  • unable to find specified revision ... in history - --to-revision out of range or pruned
  • deployments.apps "api" not found - wrong name or namespace

Key takeaways

  • Reverts a workload to a previous revision from its rollout history.
  • Use it as an automated rescue when smoke tests fail post-deploy.
  • History is bounded by revisionHistoryLimit; older revisions may be gone.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →