0

I have two different deployments that I need to have their pods be scheduled in different nodes in the cluster. For this I am adding this podAntiAffinity configuration:

  template:
    metadata:
      labels:
        run: docker
        dind: iprd-net
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: dind
                operator: Exists
            topologyKey: kubernetes.io/hostname

But it is not working. I get pods from both deployments be scheduled to the same node. As I understand it, I am adding the label "dind" (with a value). And my podAntiAffinity label selector should not choose any node (in the hostname topology, which effectly should bean any node as each node has a different hostname) that does NOT have that label (dind).

What am I missing?

4
  • What does the other deployment look like? As written, you have an anti-affinity between pods created by this deployment and pods with the label dind. Since these pods have label dind, this will ensure that pods created by this deployment are spread across multiple hosts.
    – larsks
    Commented Jun 14 at 15:07
  • The other deployment has same code. That’s the point. It is not working as sometimes both pods get scheduled in same node.
    – icordoba
    Commented Jun 15 at 18:25
  • How many pods are you deploying? Are there more pods than there are nodes?
    – larsks
    Commented Jun 15 at 20:50
  • I am just deploying 2 pods, each through a deployment, each with the described podAntiAffinity. The cluster has 4 nodes.
    – icordoba
    Commented Jun 16 at 21:37

0

You must log in to answer this question.

Browse other questions tagged .