Home > Back-end >  Kuberentes - run pods from "Deployment X" only on nodes where pods from "Deployment Y
Kuberentes - run pods from "Deployment X" only on nodes where pods from "Deployment Y

Time:08-18

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.

CodePudding user response:

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.

  • Related