<p>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.</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity" rel="nofollow noreferrer">inter pod affinity and Anti affinity</a>. Here is the relevant snippet from the documentation:</p>
<blockquote>
<p>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.</p>
<p>Inter-pod affinity and anti-affinity rules take the form &quot;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&quot;, 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.</p>
</blockquote>
