Kubernetes Deployments: Rollbacks & Rolling Restarts
In this guide, weβll learn how to:
- Rollback a Deployment to a previous version
- Rollback to a specific revision
- Perform Rolling Restarts of an application
By the end, youβll understand how Kubernetes ensures safe rollbacks and seamless restarts with zero downtime.
π Step 00: Introduction
Kubernetes provides two main rollback strategies:
- Rollback to Previous Version β Quickly revert to the last known good state.
- Rollback to Specific Revision β Revert to any earlier revision tracked in rollout history.
Additionally, Rolling Restarts allow you to restart pods in a controlled, zero-downtime manner.
πΉ Step 01: Rollback Deployment to Previous Version
1οΈβ£ Check Rollout History
kubectl rollout history deployment/my-first-deployment
2οΈβ£ Review Each Revision
Check annotations and images used in previous revisions.
kubectl rollout history deployment/my-first-deployment --revision=1
kubectl rollout history deployment/my-first-deployment --revision=2
kubectl rollout history deployment/my-first-deployment --revision=3
3οΈβ£ Rollback to Previous Version
This will rollback to the last working revision.
kubectl rollout undo deployment/my-first-deployment
Verify history again:
kubectl rollout history deployment/my-first-deployment
π Observation: The rollback creates a new revision (example: rollback from v3 β v2 becomes revision 4).
4οΈβ£ Verify Deployment, Pods, and ReplicaSets
kubectl get deploy
kubectl get rs
kubectl get po
kubectl describe deploy my-first-deployment
5οΈβ£ Access Application via Public IP
kubectl get svc
http://<External-IP>
β You should see Application Version: V2.
πΉ Step 02: Rollback Deployment to a Specific Revision
1οΈβ£ Check Rollout History
kubectl rollout history deployment/my-first-deployment
2οΈβ£ Rollback to a Specific Revision (Example: Revision 3)
kubectl rollout undo deployment/my-first-deployment --to-revision=3
3οΈβ£ Verify History
kubectl rollout history deployment/my-first-deployment
π Observation: Rolling back to revision 3 creates a new revision 5 entry in rollout history.
4οΈβ£ Access Application via Public IP
kubectl get svc
http://<External-IP>
β You should now see Application Version: V3.
πΉ Step 03: Rolling Restarts of Application
Sometimes you just need to restart all Pods without changing the image. Rolling restarts replace Pods one by one, avoiding downtime.
# Rolling Restart
kubectl rollout restart deployment/my-first-deployment
# Verify Pods are being recreated
kubectl get po
π Observation: Old Pods terminate gracefully, and new Pods come online one by one.
β Recap
In this guide, we covered:
- Rollback to previous version β Fast recovery from failures
- Rollback to specific revision β Granular control with revision history
- Rolling restarts β Safely refresh all Pods without downtime
π― With Kubernetes in GCP, you get built-in resilience, fast recovery, and seamless restarts.
π Thanks for reading! If this post added value, a like β€οΈ, follow, or share would encourage me to keep creating more content.
β Latchu | Senior DevOps & Cloud Engineer
βοΈ AWS | GCP | βΈοΈ Kubernetes | π Security | β‘ Automation
π Sharing hands-on guides, best practices & real-world cloud solutions
Top comments (0)