Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
K8s Workloads Kubernetes Kubernetes: From Zero to Production Module 6 - Scheduling and Scaling

Rolling Updates and Rollbacks in Kubernetes

Reviewed & accurate
AI Summary

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=1
Zero 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

StrategyHow it works
RollingUpdate (default)Replace Pods one by one
RecreateKill 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.
Previously: Lesson 34 covered VPA.
Today: You learned: Zero-downtime updates and instant rollbacks.
Next: Module 6 complete! Module 7 begins with lesson 36.
Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments