Running workloadsLesson 3 of 14
Zero-Downtime Deploys (Rolling Update)
Three pods running nginx 1.26 move to 1.27. During the change, user requests are never interrupted. Let's see how.
v1 pods3
v2 pods0
Pods serving3
RequestAppears in a later step
What you will learn
- How Deployment, ReplicaSet, and pods relate
- Why old pods shrink only after new pods are Ready
- How maxSurge and maxUnavailable set the pace
- Why rollback (rollout undo) is fast
Rolling update settings at a glance
| Setting | Meaning | If increased |
|---|---|---|
maxSurge | How many pods may briefly exist above the desired count | Finishes faster, but needs more spare resources |
maxUnavailable | How many pods may briefly be missing below the desired count | Finishes faster, but capacity drops for a while |
readinessProbe | Checks whether a new pod may receive requests | Without it, pods get requests as soon as they start, which can cause errors |
Try it yourself
kubectl create deployment try-web --image=nginx:1.26 --replicas=3 # Throwaway Deployment
kubectl set image deployment/try-web nginx=nginx:1.27 # Change the image
kubectl rollout status deployment/try-web # Watch until done
kubectl get rs -l app=try-web # Old ReplicaSet stays at 0
kubectl rollout undo deployment/try-web # Roll back to 1.26
kubectl delete deployment try-web # Clean up
Check yourself
Further reading: Deployments · Performing a Rolling Update