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)