0
0
Kubernetesdevops~30 mins

Rollback to previous version in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Rollback to Previous Version in Kubernetes
📖 Scenario: You are managing a web application deployed on Kubernetes. After updating the application to a new version, you notice issues and want to rollback to the previous stable version.
🎯 Goal: Learn how to rollback a Kubernetes deployment to its previous version using kubectl commands.
📋 What You'll Learn
Create a Kubernetes deployment named webapp with version v1 of the container image
Update the deployment to version v2 of the container image
Rollback the deployment to the previous version
Display the current image version of the deployment after rollback
💡 Why This Matters
🌍 Real World
In real-world Kubernetes environments, deployments are frequently updated. Sometimes new versions cause issues. Knowing how to quickly rollback to a stable version helps keep applications running smoothly.
💼 Career
DevOps engineers and site reliability engineers often manage Kubernetes deployments. Mastering rollback commands is essential for maintaining application uptime and reliability.
Progress0 / 4 steps
1
Create initial deployment with version v1
Use kubectl create deployment webapp --image=nginx:1.19 to create a deployment named webapp with the image version 1.19 (representing version v1).
Kubernetes
Need a hint?

This command creates a deployment named webapp using the nginx image version 1.19.

2
Update deployment to version v2
Use kubectl set image deployment/webapp webapp=nginx:1.20 to update the webapp deployment's container image to version 1.20 (representing version v2).
Kubernetes
Need a hint?

This command updates the container image of the webapp deployment to nginx version 1.20.

3
Rollback deployment to previous version
Use kubectl rollout undo deployment/webapp to rollback the webapp deployment to its previous version.
Kubernetes
Need a hint?

This command rolls back the deployment to the last stable version before the update.

4
Check current image version after rollback
Use kubectl get deployment webapp -o=jsonpath='{.spec.template.spec.containers[0].image}' to display the current container image version of the webapp deployment after rollback.
Kubernetes
Need a hint?

This command prints the current image used by the deployment, which should be nginx:1.19 after rollback.