StatefulSet behavior when a node dies/gets restarted and has a PersistentVolume

6/18/2018

Suppose I have a resource foo which is a statefulset with 3 replicas. Each makes a persistent volume claim.

One of the foo pods (foo-1) dies, and a new one starts in its place. Will foo-1 be bound to the same persistent volume that the previous foo-1 had before it died? Will the number of persistent volume claims stay the same or grow?

This edge case doesn't seem to be in the documentation on StatefulSets.

-- FrobberOfBits
google-kubernetes-engine
kubernetes
persistent-storage
statefulset

1 Answer

6/18/2018

Yes you can. A PVC is going to create a disk on GCP, and add it as secondary disk to the node in which the pod is running.

Upon deletion of an individual pod, K8s is going to re-create the pod on the same node it was running. If it is not possible (say the node no longer exists), the pod will be created on another node, and the secondary disk will be moved to that node.

-- suren
Source: StackOverflow