How can i set max count of pods for replication-controller per node?

1.2k Views Asked by At

I have a question.

Let's imagine a situation.

For example: We have three node within the cluster. And we have replication-controller where we have spec: replicas: 3

I would like to have not more one pod per node. Because if one node will have more one pod while node die, i'll lose two or more pods.

How can i do that?

1

There are 1 best solutions below

2
On

The Kubernetes scheduler already prioritizes spreading pods from the same replication controller out across your nodes.

However, if you want to be 100% sure that no two pods will end up on the same node, you can set the container's HostPort field. No two containers with the same HostPort can ever run on the same node.

If you want to get even fancier, you could write your own scheduler plugin :)

In general, though, the idea of Kubernetes is that you shouldn't have to think about your nodes except in special circumstances; you can instead trust the system to keep your applications running.