How to Check Rollout History in Kubernetes
Use the
kubectl rollout history command followed by the resource type and name to view the rollout history of a Kubernetes deployment. For example, kubectl rollout history deployment/my-deployment shows all revisions and changes made to that deployment.Syntax
The basic syntax to check rollout history in Kubernetes is:
kubectl rollout history <resource_type>/<resource_name>: Shows the rollout history of the specified resource.--revision=<number>: Optional flag to view details of a specific revision.
bash
kubectl rollout history deployment/my-deployment
kubectl rollout history deployment/my-deployment --revision=2Example
This example shows how to check the rollout history of a deployment named nginx-deployment and view details of revision 3.
bash
kubectl rollout history deployment/nginx-deployment
kubectl rollout history deployment/nginx-deployment --revision=3Output
deployment.apps/nginx-deployment
REVISION CHANGE-CAUSE
1 Initial deployment
2 Updated image to nginx:1.19
3 Updated image to nginx:1.20
deployment.apps/nginx-deployment with revision #3
Pod Template:
Containers:
nginx:
Image: nginx:1.20
Port: 80/TCP
Common Pitfalls
Common mistakes when checking rollout history include:
- Using the wrong resource type (e.g.,
podinstead ofdeployment). - Not specifying the resource name correctly.
- Expecting rollout history for resources that do not support it (only deployments, daemonsets, and statefulsets support rollout history).
- Forgetting to use
--revisionto see details of a specific revision.
bash
kubectl rollout history pod/nginx-pod # Wrong resource type, will show error kubectl rollout history deployment/nginx-deployment --revision=100 # Revision does not exist, will show error
Quick Reference
| Command | Description |
|---|---|
| kubectl rollout history deployment/ | Show rollout history of a deployment |
| kubectl rollout history deployment/ | Show details of a specific revision |
| kubectl rollout undo deployment/ | Rollback to previous revision |
| kubectl rollout status deployment/ | Check current rollout status |
Key Takeaways
Use 'kubectl rollout history deployment/' to see all revisions of a deployment.
Add '--revision=' to view details of a specific rollout revision.
Rollout history works for deployments, daemonsets, and statefulsets only.
Ensure you specify the correct resource type and name to avoid errors.
Use rollout history to track changes and troubleshoot deployment rollbacks.