What You Will Learn
Beginner
- How rolling updates work
- How to update a Deployment
- How to rollback
Terminalbash
# Update the image (triggers rolling update)
kubectl set image deployment/my-app app=my-app:v2
# Watch the rollout
kubectl rollout status deployment/my-app
# Waiting for deployment to complete...
# deployment my-app successfully rolled out
# Check rollout history
kubectl rollout history deployment/my-app
# REVISION CHANGE-CAUSE
# 1 kubectl apply --filename=...
# 2 kubectl set image deployment/my-app...
# Rollback to previous version
kubectl rollout undo deployment/my-app
# Rollback to specific revision
kubectl rollout undo deployment/my-app --to-revision=1Zero downtime
K8s creates the new Pod, waits for it to be healthy (readiness probe), then removes an old Pod. Repeat for all replicas. No downtime for users!Update Strategies
| Strategy | How it works |
|---|---|
| RollingUpdate (default) | Replace Pods one by one |
| Recreate | Kill all old Pods, then create new (downtime!) |
Practical Exercise
Create a Deployment with v1 image
Update: kubectl set image deployment/my-app app=nginx:1.26
Watch: kubectl rollout status deployment/my-app
Check history: kubectl rollout history deployment/my-app
Rollback: kubectl rollout undo deployment/my-app
Key Takeaways
- Rolling update: replace Pods one by one (zero downtime).
- kubectl set image: triggers update.
- kubectl rollout status: watch progress.
- kubectl rollout undo: instant rollback.
- kubectl rollout history: see all revisions.
Comments
Comments
Post a Comment