I have simple issue with StatefulSet update on my dev environment and CI.
I want to replace all StatefulSet replicas instantly without using Kubectl delete first. Is it possible to change the manifest to strategy: Replace as in Deployments and continue using kubectl apply ...
Currently the StatefulSets support only two kinds of update strategies:
RollingUpdate
: The RollingUpdate
update strategy implements automated, rolling update for the Pods in a StatefulSet. It is the default strategy when .spec.updateStrategy
is left unspecified. When a StatefulSet's .spec.updateStrategy.type
is set to RollingUpdate
, the StatefulSet controller will delete and recreate each Pod in the StatefulSet. It will proceed in the same order as Pod termination (from the largest ordinal to the smallest), updating each Pod one at a time. It will wait until an updated Pod is Running and Ready prior to updating its predecessor.
OnDelete
: The OnDelete
update strategy implements the legacy (1.6 and prior) behavior. When a StatefulSet's .spec.updateStrategy.type
is set to OnDelete
, the StatefulSet controller will not automatically update the Pods in a StatefulSet. Users must manually delete Pods to cause the controller to create new Pods that reflect modifications made to a StatefulSet's .spec.template
.
However, there is a plan to implement a MaxUnavailable Rolling Update to StatefulSet. It would allow you to update X number of replicas together based on a maxUnavailble
strategy. It led to this update proposal but it is not done yet and judging from the latest comments it should be set as a milestone for Kubernetes 1.20.