Skip to main content

Command Palette

Search for a command to run...

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

Published
β€’3 min read
πŸ”„ Revert Deployment to Previous Version in Kubernetes (Step-by-Step Guide)
B

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-deployment

  • Goal: 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