kubectl rollout history

View the rollout history of a resource, including revision numbers and change causes.

kubectl rollout history [TYPE] [NAME] [flags]

Common Flags

FlagShortDescription
--revisionView the details of a specific revision number
--namespace-nNamespace of the resource
--output-oOutput format for revision details

Examples

View rollout history of a deployment

kubectl rollout history deployment/my-app

View details of a specific revision

kubectl rollout history deployment/my-app --revision=3

View history of a DaemonSet

kubectl rollout history daemonset/fluentd -n kube-system

View revision details as YAML

kubectl rollout history deployment/my-app --revision=2 -o yaml

View history of a StatefulSet

kubectl rollout history statefulset/postgresql

When to Use kubectl rollout history

kubectl rollout history shows the revision history of a deployment, DaemonSet, or StatefulSet. Each change to the pod template creates a new revision. The history allows you to inspect what changed in each revision and decide which revision to roll back to if needed.

Viewing History

# View the revision list
kubectl rollout history deployment/my-app
# REVISION  CHANGE-CAUSE
# 1         Initial deployment
# 2         Updated image to v1.2
# 3         Updated image to v1.3
# 4         Added resource limits

The CHANGE-CAUSE column shows the value of the kubernetes.io/change-cause annotation at the time of each revision. Without this annotation, the column shows <none>.

Adding Change Causes

Document your changes by annotating the deployment before or after the update:

# Annotate after applying changes
kubectl apply -f deployment.yaml
kubectl annotate deployment/my-app kubernetes.io/change-cause="Deployed v2.1 with new logging config"

# Or set the annotation in the YAML manifest
# metadata:
#   annotations:
#     kubernetes.io/change-cause: "v2.1 release"

Meaningful change causes make the history actionable. When reviewing the history during an incident, you can quickly identify which change might have caused the problem.

Inspecting Specific Revisions

Use --revision to see the full pod template of a specific revision:

# View details of revision 3
kubectl rollout history deployment/my-app --revision=3

# Output includes:
# - Container images
# - Environment variables
# - Resource requests and limits
# - Volume mounts
# - Labels and annotations

# Get the full YAML for a revision
kubectl rollout history deployment/my-app --revision=3 -o yaml

Comparing Revisions

To understand what changed between revisions, inspect each one:

# Compare revision 2 and 3
kubectl rollout history deployment/my-app --revision=2 > rev2.yaml
kubectl rollout history deployment/my-app --revision=3 > rev3.yaml
diff rev2.yaml rev3.yaml

This shows exactly which fields changed, making it clear whether the issue is an image change, an environment variable update, or a resource limit modification.

Revision History Limit

Kubernetes retains old ReplicaSets to enable rollbacks. The revisionHistoryLimit field controls how many are kept:

spec:
  revisionHistoryLimit: 10  # default

Each old ReplicaSet corresponds to a revision. When the limit is reached, the oldest ReplicaSets are garbage collected. Setting this too low limits your rollback options. Setting it too high wastes etcd storage.

# Check the current revision history limit
kubectl get deployment my-app -o jsonpath='{.spec.revisionHistoryLimit}'

# View all ReplicaSets (each is a revision)
kubectl get rs -l app=my-app --sort-by=.metadata.creationTimestamp

Using History for Incident Response

During an incident, the rollout history helps determine when the problem started:

# Step 1: View the history
kubectl rollout history deployment/my-app

# Step 2: Identify the suspicious revision
kubectl rollout history deployment/my-app --revision=4

# Step 3: Compare with the last known good revision
kubectl rollout history deployment/my-app --revision=3

# Step 4: Roll back if needed
kubectl rollout undo deployment/my-app --to-revision=3

History Across Resource Types

Rollout history works with any resource type that supports rolling updates:

# Deployment history
kubectl rollout history deployment/my-app

# DaemonSet history
kubectl rollout history daemonset/node-exporter -n monitoring

# StatefulSet history
kubectl rollout history statefulset/postgresql -n databases

Best Practices

Always annotate deployments with meaningful change causes. Set revisionHistoryLimit to a value that balances storage with rollback flexibility (10 is a reasonable default). Regularly review history during incidents to correlate deployment changes with issues. Include the change cause annotation in your CI/CD pipeline so every automated deployment is documented. Store revision details alongside deployment manifests in your version control for long-term audit trails.

Interview Questions About This Command

How do you see what changed between deployment revisions?
Use kubectl rollout history deployment/<name> --revision=N for each revision to compare the pod templates. The output shows the container images, environment variables, and other template fields for that revision.
What determines the number of revisions kept in history?
The spec.revisionHistoryLimit field on the Deployment controls how many old ReplicaSets are kept. The default is 10. Each old ReplicaSet corresponds to a revision in the history.
How do you add a meaningful change cause to the rollout history?
Annotate the deployment with kubernetes.io/change-cause: kubectl annotate deployment/my-app kubernetes.io/change-cause='Updated image to v2.1'. This annotation appears in the CHANGE-CAUSE column of rollout history.

Common Mistakes

  • Expecting detailed change diffs in the history output — it only shows revision numbers and change causes. Use --revision=N to see the full pod template for each revision.
  • Setting revisionHistoryLimit too low and losing the ability to roll back to earlier revisions.
  • Not annotating deployments with change causes, resulting in empty CHANGE-CAUSE columns that make history useless.

Related Commands