Limit replicas per node on Kubernetes

5/28/2020

Is there a way to limit the number os replicas per node in Kubernetes? I found some info about Spreading Constraints but didn't understand if this is possible.

Example: I want to have only 1 replica per node on the cluster.

I know that K8S automatically balances the replicas spreading across the nodes, but I want to enforce a specific limit in each node.

Is this possible?

-- Hugo Marques
kubernetes

3 Answers

5/28/2020

The scheduler has many ways to just about everything but in the particular case of 1 replica per node you can use a required mode anti-affinity.

-- coderanger
Source: StackOverflow

5/28/2020

If you want to ensure that all nodes have single replica on them you can use a DaemonSet.

-- hoque
Source: StackOverflow

5/28/2020

You can create daemon set which makes sure every node in the cluster runs exactly one replica

-- slashpai
Source: StackOverflow