---
source: https://iinventedlight.com/library/notes/kubernetes-rollout-undo.md
title: "kubectl rollout undo rolls a Deployment back to an earlier revision"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (Kubernetes docs); CC-BY-4.0 (kubernetes/website (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, kubectl rollout undo; kubernetes/website (GitHub), Deployments (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Kubernetes rollout undo"
tags: [kubernetes, kubectl, rollout, rollback, deployment, revisionHistoryLimit]
client: Librarian
sources:
  - id: S1
    title: "kubectl rollout undo"
    publisher: Kubernetes docs
    url: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_undo/
    accessed: 2026-11-18
    license: "CC-BY-4.0"
  - id: S2
    title: "Deployments (source page)"
    publisher: kubernetes/website (GitHub)
    url: https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/workloads/controllers/deployment.md
    accessed: 2026-11-18
    license: "CC-BY-4.0"
---
# kubectl rollout undo rolls a Deployment back to an earlier revision
**Answer:** `kubectl rollout undo deployment/NAME` rolls back to the previous rollout. Add `--to-revision=N` to roll back to a specific revision, and check the revisions first with `kubectl rollout history`.

## Commands

```shell
kubectl rollout history deployment/nginx-deployment
kubectl rollout history deployment/nginx-deployment --revision=2
kubectl rollout undo deployment/nginx-deployment
kubectl rollout undo deployment/nginx-deployment --to-revision=2
kubectl rollout undo --dry-run=server deployment/abc
```

The same command also works on other rollout types, for example `kubectl rollout undo daemonset/abc --to-revision=3`. With `--dry-run=server`, kubectl submits a server-side request without persisting the resource.

## Where the history comes from

The system keeps all of a Deployment's rollout history by default, so you can roll back anytime. The configuration of each Deployment revision is stored in its ReplicaSets; once an old ReplicaSet is deleted, you lose the ability to roll back to that revision.

`.spec.revisionHistoryLimit` sets how many old ReplicaSets to retain to allow rollback. By default, 10 old ReplicaSets will be kept. The rest will be garbage-collected in the background.

## Recording why a revision exists

The `CHANGE-CAUSE` column in `kubectl rollout history` is copied from the Deployment annotation `kubernetes.io/change-cause`. Set it by annotating the Deployment, for example with `kubectl annotate`. The older `--record` flag is deprecated.

## See also

- [kubernetes-deployments](https://iinventedlight.com/library/notes/kubernetes-deployments/)
- [kubernetes-kubectl-basics](https://iinventedlight.com/library/notes/kubernetes-kubectl-basics/)
- [kubernetes-labels-selectors](https://iinventedlight.com/library/notes/kubernetes-labels-selectors/)

## Claims

- id: C1
  claim: The command rolls back to a previous rollout.
  source: S1
  evidence: "Roll back to a previous rollout."

- id: C2
  claim: Server dry-run submits the request without persisting the resource.
  source: S1
  evidence: "submit server-side request without persisting the resource"

- id: C3
  claim: Use --to-revision to roll back to a specific revision.
  source: S2
  evidence: "you can rollback to a specific revision by specifying it with"

- id: C4
  claim: Ten old ReplicaSets are kept by default.
  source: S2
  evidence: "By default, 10 old ReplicaSets will be kept"

## Sources

- [S1] kubectl rollout undo. Kubernetes docs. https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_undo/ . License: CC-BY-4.0. Accessed 2026-11-18.

- [S2] Deployments (source page). kubernetes/website (GitHub). https://github.com/kubernetes/website/blob/main/content/en/docs/concepts/workloads/controllers/deployment.md . License: CC-BY-4.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Kubernetes docs, kubectl rollout undo; kubernetes/website (GitHub), Deployments (source page). CC-BY-4.0 (https://raw.githubusercontent.com/kubernetes/website/main/LICENSE). Copyright The Kubernetes Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
