Search code examples
kuberneteskubernetes-statefulset

Stateful set with `updateStrategy.type: OnDelete` does not instantiate new version of Pod when it exits


I am currently upgrading my MongoDB sharded cluster. To do this, I am using the OnDelete update strategy on my stateful set so that I can shut down the secondary nodes first and then the primary nodes. However, as soon as I run db.adminCommand( { shutdown: 1 } ) and the pod is shut down, a new pod is created, but still with the old template. This was somewhat unexpected for me as the template is already updated in the stateful set.

Is this the expected behaviour or a bug or am I missing something?

Thanks in advance and best regards
Ledex


Solution

  • k8s documentation says:

    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.

    You need to explicitly delete your pod, i.e. kubectl delete pod. Shutting down the container process is not the same apparently.