Search code examples
kubernetesschedulingstatefulset

Kubernetes StatefulSets - run pod on every worker node


What is the easiest way to run a single Pod on every available worker node as part of the StatefulSet. So, a one to one mapping.

Am I right to say every Pod will run on a different Node by default with a StatefulSet? In which case is it sufficient to add x pods to the SS where x Worker nodes exist in the cluster?

Thanks.


Solution

  • Use DaemonSet instead.

    A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.

    If you really want to use statefulSet, you can take a look at features like nodeSelector or Affinity and Anti-affinity.