3

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 ...

mkasepuu
  • 243
  • 5
  • 13

1 Answers1

3

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.

Jude Niroshan
  • 4,280
  • 8
  • 40
  • 62
Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
  • @user3077014 Does it answer your question? – Wytrzymały Wiktor Nov 02 '20 at 08:15
  • If RollingUpdate strategy of statefulsets may bring downtime when pods are restarted using "kubectl rollout restart sts/mysts -n mynamespace"? I can see the official documentation says it will be zero downtime with rolling update but it gives example of deployments. not statefulset. https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/ Could someone help me? – Deepak Gangore Dec 15 '21 at 06:21