2

I need to set my deployment to have at least one pod on each node so that the system will continue uninterrupted in case the node goes down. I can set this to run one pod per node with daemonset or podAntiAffinity. But what I really want is that there is at least one pod in each node and all pods can be scheduled if there are more replicas than the number of nodes.

How can I do that? Thank you for your answers

Enes Uysal
  • 23
  • 1
  • 3

1 Answers1

2

You can use topologySpreadConstaints for spreading Deployment pods evenly across nodes, regardless of the number of pods. Kubernetes documentation contains multiple examples, as well as following article - Kubernetes: Evenly Distribution of Pods Across Cluster Nodes.

The .spec.teplate.spec would look something like:

    spec:
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: kubernetes.io/hostname
          whenUnsatisfiable: ScheduleAnyway
          labelSelector:
            matchLabels:
              type: dummy    
David Lukac
  • 156
  • 7