Dino L.
Dino L.

Reputation: 137

Kuberentes - run pods from "Deployment X" only on nodes where pods from "Deployment Y" do not exist

I want to deploy some pods (from deployment X) only on nodes where pods from deployment Y do not exist. Is there a way to make something like that? First idea is to use node affinity and deploy X on nodes with label X and Y where there is no X, but I would like to avoid that.

Upvotes: 1

Views: 45

Answers (1)

P....
P....

Reputation: 18351

You can use inter pod affinity and Anti affinity. Here is the relevant snippet from the documentation:

Inter-pod affinity and anti-affinity allow you to constrain which nodes your Pods can be scheduled on based on the labels of Pods already running on that node, instead of the node labels.

Inter-pod affinity and anti-affinity rules take 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", where X is a topology domain like node, rack, cloud provider zone or region, or similar and Y is the rule Kubernetes tries to satisfy.

Upvotes: 1

Related Questions