StatefulSet Update Strategy
How does a change to the Pod template reach a StatefulSet that is already running? RollingUpdate deletes and recreates the Pods one at a time from the largest ordinal down, waiting for each to be Running and Ready before it touches the predecessor. A partition freezes every ordinal below it so you can stage a canary, maxUnavailable widens the window past one where its Beta gate is enabled, and OnDelete hands the trigger back to you.
Play the animation 6 steps, animated, best on a wide screen
StatefulSet Update Strategy, step by step
-
Your edit to spec.template reaches the controller off its watch, and it stores that template as a ControllerRevision with the next revision number. Nothing has moved: all four replicas still run the revision before it. The default spec.updateStrategy.type is RollingUpdate, and that is what turns a new revision into a rollout.
Play from step 1 -
A RollingUpdate deletes and recreates each Pod, and it proceeds in the same order as termination, from the largest ordinal to the smallest. So the walk opens at web-3 and never at web-0. The Pod comes back built from rev 3, and it is the only member of the set that is unavailable while it does.
Play from step 2 -
The control plane waits until the updated Pod is Running and Ready before it touches the predecessor, and where spec.minReadySeconds is set it waits that long again after the Pod turns ready. Only then does web-2 go. The second slot stays empty throughout, because the maxUnavailable budget is 1.
Play from step 3 -
Setting spec.updateStrategy.rollingUpdate.partition to 2 draws a line through the set. Every ordinal at or above 2 is updated and every ordinal below it is left alone, and a Pod under the line is recreated at the previous revision even if you delete it. That is how a canary or a phased rollout is staged.
Play from step 4 -
With the MaxUnavailableStatefulSet gate on and podManagementPolicy Parallel, set spec.updateStrategy.rollingUpdate.maxUnavailable to 2 and partition back to 0, and web-1 and web-0 are replaced together. OrderedReady still recreates them in order. The Beta gate is off by default since 1.35.4. Every replica now runs rev 3.
Play from step 5 -
The other strategy hands the trigger back. With spec.updateStrategy.type set to OnDelete a further edit to spec.template still records rev 4, but the controller updates nothing by itself, so every replica stays on the revision it has until you delete a Pod yourself. Your deletions become the rollout.
Play from step 6