π Revert Deployment to Previous Version in Kubernetes (Step-by-Step Guide)

I am Bittu Sharma, a DevOps & AI Engineer with a keen interest in building intelligent, automated systems. My goal is to bridge the gap between software engineering and data science, ensuring scalable deployments and efficient model operations in production.! ππ²π'π ππΌπ»π»π²π°π I would love the opportunity to connect and contribute. Feel free to DM me on LinkedIn itself or reach out to me at bittush9534@gmail.com. I look forward to connecting and networking with people in this exciting Tech World.
Even with proper testing, bugs can sometimes slip into production. Kubernetes makes it easy to rollback a Deployment to a previous stable version using its built-in rollout history.
In this guide, weβll walk through how the Nautilus DevOps team can revert an application to its previous version after detecting an issue in the latest release.
π§ Scenario Overview
A new version of an application was deployed earlier today
Customers reported a bug in the latest release
The application is managed by a Deployment named
nginx-deploymentGoal: Rollback the Deployment to the previous revision and ensure all Pods are healthy
π What Is a Deployment Rollback?
A rollback:
Restores the Deployment to a previous revision
Recreates Pods using the older configuration/image
Helps recover quickly from faulty releases
Minimizes downtime and risk
Kubernetes automatically maintains a revision history for Deployments.
π§© Step 1: Roll Back to the Previous Revision
Use the following command to revert the Deployment to its last stable version:
kubectl rollout undo deployment nginx-deployment
β Expected Output
deployment.apps/nginx-deployment rolled back
Kubernetes will now:
Terminate Pods running the faulty version
Recreate Pods using the previous revision
Maintain availability during the rollback
π Step 2: Monitor the Rollback Status
Check the rollout status to ensure the rollback completes successfully:
kubectl rollout status deployment nginx-deployment
π’ Sample Output
deployment "nginx-deployment" successfully rolled out
β³ If the rollback is still in progress, Kubernetes will display live status updates.
π¦ Step 3: Verify the Pods
Confirm that all Pods are running and healthy:
kubectl get pods
π’ Sample Output
NAME READY STATUS RESTARTS AGE
nginx-deployment-5d9f7c6f8b-x2kqj 1/1 Running 0 30s
nginx-deployment-5d9f7c6f8b-p9wld 1/1 Running 0 28s
All Pods should be in the Running state with READY = 1/1.
π§Ύ Optional: Check Rollout History
To view the revision history of the Deployment:
kubectl rollout history deployment nginx-deployment
This helps you:
Identify previous versions
Roll back to a specific revision if needed
π οΈ Roll Back to a Specific Revision (Optional)
If you want to roll back to a specific revision number:
kubectl rollout undo deployment nginx-deployment --to-revision=1
π― Conclusion
In this guide, you learned how to:
Roll back a Kubernetes Deployment to a previous version
Monitor rollback progress
Verify application health after rollback
Inspect Deployment rollout history
Rollback is a critical production skill that allows teams to respond quickly to failures and maintain system stability.
π Next Steps
Great follow-up topics for your next Kubernetes blog:
Rolling Updates vs Rollbacks
Canary deployments in Kubernetes
Blue-Green deployment strategies
Managing Deployment revision history
Zero-downtime release strategies




