3
votes

Is there a way to deploy a replica set in Kubernetes on unique nodes?

All the documentation I can find on Kubernetes NodeSelectors, (anti-)affinity, etc., seems to relate to specifying a particular node you do or don't want the pods to be on. I don't mind which nodes my pods are on, I just don't want two pods from a deployment on the same one-- I want to spread them out.

It seems like a simple enough thing to do-- in Mesos you can apply a constraint like "HOSTNAME: unique" to achieve it-- but I can't find the Kubernetes equivalent. Can anyone help, please?

1
Possible duplicate, check first answer.Szymon Maszke
Thanks, I did check, but you're right- it's a duplicate question.hiiamelliott
I think first answer is correct with pod anti-affinity. First answer of the possible duplicate seems overly complicated.Joshua Oliphant

1 Answers

2
votes

In contrast with the first answer described in the comments below your question I'd say the right approach is to define pod anti-affinity as described in the docs. More precisely:

The rules are of the form “this pod should (or, in the case of anti-affinity, should not) run in an X if that X is already running one or more pods that meet rule Y”.

Feel free to share your scenario details in order to propose a solution. Of course, if you want to run your deployment on compute plane exclusively or compute + control plane you'd choose Deployment resp. DaemonSet in case of the latter.