Scheduling & Rolling Updates
Docker & Kubernetes for Interviews: lesson 6 of 12
Where a Pod lands, and how v1 becomes v2 without a gap in service.
Lesson 6 of 12 · 7 min
Scheduling & Rolling Updates
Step 1 of 13
A new Pod requests 500m of CPU. Until the scheduler binds it to a node, it is Pending.
The Idea
The scheduler places each new Pod: it filters out nodes that cannot fit its resource requests and constraints, scores the rest, and binds the Pod to the best one. If none fits, the Pod stays Pending. A rolling update replaces Pods gradually: maxSurge caps extra Pods above the desired count, maxUnavailable caps how many may be missing. Both default to 25%.
Real-World Example
A Deployment of four moves from v1 to v2. With the defaults, at most five Pods exist and at least three are available at every moment. If v2 never becomes ready, the rollout stalls with v1 still serving.
The Tradeoff
maxSurge: 0 needs no spare capacity but dips below full strength; maxUnavailable: 0 never dips but needs room for the extra Pod. kubectl rollout undo returns to the previous ReplicaSet.
Hands-On
# illustrative — the rolling-update knobs on a Deployment
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate: { maxSurge: 1, maxUnavailable: 0 }
# illustrative — ship v2, watch it, and step back if needed
kubectl set image deployment/api api=registry.example.com/api:2.0.0
kubectl rollout status deployment/api
kubectl rollout undo deployment/api
Your turn
Put the steps in the right order.
- The old ReplicaSet scales down by one v1 Pod
- You change the image in the Pod template
- The v2 Pod passes readiness and counts as available
- A new ReplicaSet creates one v2 Pod (the surge)
- Repeat until all four Pods run v2
Mini quiz
1 / 3
replicas: 4 with the default maxSurge and maxUnavailable (25% each). During a rollout the Deployment keeps:
Sources
- Kubernetes Scheduler — Kubernetes Documentation
- Deployments: rolling update strategy — Kubernetes Documentation
- Resource management for Pods and containers — Kubernetes Documentation