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 prodCommon 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
kubectl rollout status: Gate Deploys in CIWait for a Kubernetes rollout to finish in CI: timeout flags, a gating example, and the errors that mean a st…
kubectl set image: Update Deployment Images in CIUpdate a container image on a Deployment from CI: syntax, a rollout example, and the errors that come from wr…
helm rollback: Revert Releases in CIRoll a Helm release back to a previous revision in CI: revision and wait flags, an example, and the rollback…