0
0
Kubernetesdevops~10 mins

Rollback to previous version in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Rollback to previous version
Check current deployment version
Identify previous stable version
Run rollback command
Kubernetes updates deployment
Verify rollback success
END
This flow shows how Kubernetes rolls back a deployment to a previous version by checking current state, applying rollback, and verifying success.
Execution Sample
Kubernetes
kubectl rollout undo deployment/my-app
kubectl rollout status deployment/my-app
Rollback the deployment 'my-app' to its previous version and check the status.
Process Table
StepActionCommandResultNotes
1Check current deployment versionkubectl rollout status deployment/my-appDeployment is at revision 3Shows current version is 3
2Rollback to previous versionkubectl rollout undo deployment/my-appDeployment rolled back to revision 2Rollback command triggers update
3Verify rollback statuskubectl rollout status deployment/my-appDeployment successfully rolled out revision 2Confirms rollback success
4End--Rollback complete, deployment stable at revision 2
💡 Rollback stops after deployment is stable at previous revision
Status Tracker
VariableStartAfter Step 2After Step 3Final
deployment_revision32 (rollback triggered)2 (confirmed)2
Key Moments - 2 Insights
Why does the rollback command not specify the exact revision number?
By default, 'kubectl rollout undo' rolls back to the immediately previous revision, as shown in execution_table step 2, so specifying revision is optional unless you want a specific older version.
What happens if the rollback fails?
If rollback fails, the status command in step 3 would show an error or incomplete rollout, indicating the deployment did not stabilize at the previous revision.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the deployment revision after the rollback command is run?
A3
B2
C1
D4
💡 Hint
Check the 'Result' column in step 2 of the execution_table
At which step does the deployment status confirm the rollback was successful?
AStep 3
BStep 2
CStep 1
DStep 4
💡 Hint
Look at the 'Action' and 'Result' columns in step 3 of the execution_table
If you wanted to rollback to revision 1 instead of the previous one, what would you do?
ARun 'kubectl rollout restart deployment/my-app --to-revision=1'
BRun 'kubectl rollout status deployment/my-app --to-revision=1'
CRun 'kubectl rollout undo deployment/my-app --to-revision=1'
DRun 'kubectl delete deployment/my-app --to-revision=1'
💡 Hint
Refer to Kubernetes rollback syntax for specifying revision, related to step 2 command
Concept Snapshot
Rollback to previous version in Kubernetes:
- Use 'kubectl rollout undo deployment/<name>' to rollback.
- By default, rolls back to the immediately previous revision.
- Check status with 'kubectl rollout status deployment/<name>'.
- Specify revision with '--to-revision=N' if needed.
- Rollback updates deployment to stable older version.
Full Transcript
This visual execution shows how to rollback a Kubernetes deployment to a previous version. First, we check the current deployment revision using 'kubectl rollout status'. Then, we run 'kubectl rollout undo' to rollback to the previous revision. After that, we verify the rollback success again with 'kubectl rollout status'. The deployment revision changes from 3 to 2, confirming the rollback. If needed, you can specify a particular revision to rollback to using the '--to-revision' flag. This process ensures your deployment returns to a stable state if a newer version has issues.