What do maxSurge and maxUnavailable control in a RollingUpdate?
Quick Answer
They tune the rolling update's pace and safety. maxUnavailable is how many pods below the desired count you'll tolerate during the rollout; maxSurge is how many extra pods above the desired count you'll temporarily create. Together they trade speed against capacity.
Detailed Answer
During a RollingUpdate the Deployment scales the new ReplicaSet up and the old one down in steps. maxUnavailable caps how many replicas can be unavailable at once (e.g., 25% of 8 = 2 can be down) — lower means safer but slower. maxSurge caps how many extra pods can exist above the desired count (e.g., 25% = up to 10 running briefly) — higher means faster but needs spare capacity. Setting maxUnavailable: 0 with maxSurge: 1 gives a fully available, one-at-a-time rollout (no capacity dip, slower); maxSurge: 0 with maxUnavailable: 1 avoids extra capacity but runs degraded. Readiness probes are essential here: the rollout only proceeds as new pods become Ready, so a broken new version stalls the rollout instead of taking everything down — which is exactly the safety you want.
Code Example
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0 # never drop below desired capacity
maxSurge: 1 # add one extra at a time -> zero-downtime, steady paceInterview Tip
Frame it as a trade-off: maxSurge=speed via extra capacity, maxUnavailable=tolerated degradation. Then connect to readiness probes gating the rollout — that's what makes rolling updates safe.