Video in progress
In what order are the pods replaced when this Deployment is updated?
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
minReadySeconds: 10
In a rolling update with 4 replicas, Kubernetes creates at most 1 extra new pod at a time and never lets the number of ready pods drop below 4. The old pod is deleted only after the new pod passes readiness.
📖 Answer
maxSurge: 1 means there can be at most 1 pod more than the desired number (5 in total). maxUnavailable: 0 means the number of ready pods never falls below 4.
Step by step:
- One pod of the new version comes up (4 old + 1 new).
- The new pod passes readiness and stays stable for another 10 seconds (
minReadySeconds). - One old pod is deleted.
- This repeats until everything has been replaced.
This is the slow but safe variant, because capacity never drops. The default (25%/25%) is faster, but the number of pods temporarily goes down.
What to watch for in practice:
- if the readiness probe falsely says "ready", the rolling update is pointless too, and a bad version quietly spreads everywhere;
- if the new pod never becomes ready, the rollout stalls and the old pods keep working.
kubectl rollout status deploy/shop-apishows this, and afterprogressDeadlineSecondsthe Deployment goes intoProgressDeadlineExceeded; - during a rollout, old and new versions receive traffic at the same time, so the API and the DB schema must be compatible with both.
Sign up to mark studied questions and save your progress.