StatefulSet Update Strategy
You edit the template of a running StatefulSet, and its Pods are replaced one by one from the highest ordinal down, all, some or none. What sets how far the update goes, and who decides when a Pod is replaced?
Play the animation 6 steps, animated, plays on a computer or a tablet
StatefulSet Update Strategy, step by step
-
The controller learns of your spec.template edit off its watch and saves the template as a ControllerRevision with the next revision number. Nothing has moved yet, and all four replicas still run the previous revision. The default spec.updateStrategy.type is RollingUpdate, and this is what turns a new revision into a rollout.
Play from step 1 -
Under RollingUpdate the controller deletes and recreates each Pod in the same order as Pod 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 while it does, it is the only member of the set that is unavailable.
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 -
If the MaxUnavailableStatefulSet feature gate is on and podManagementPolicy is Parallel, spec.updateStrategy.rollingUpdate.maxUnavailable goes to 2 and partition back to 0. Then web-1 and web-0 are replaced together, but OrderedReady still recreates them in order. Since 1.35.4 this Beta gate is off by default. Every replica now runs rev 3.
Play from step 5 -
The other strategy hands the update trigger back to you. With spec.updateStrategy.type set to OnDelete a further edit to spec.template still records rev 4, but the controller updates nothing by itself. Each Pod keeps its revision until you delete it, and after the delete it comes back from rev 4.
Play from step 6