Score:0

Is it possible to assign pods to all matches except specific nodes in k8s?

ph flag

On a shared cluster, I'm trying to deploy my app on dedicated nodes, all have myrole role. I would like to exclude a few of these nodes by name.

This doesn't work:

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions:
            - key: "role.kubernetes.io/team"
              operator: "In"
              values:
                - "myrole"
        - matchExpressions:
            - key: "kubernetes.io/hostname"
              operator: "NotIn"
              values:
                - node_name_1
                - node_name_2

This doesn't work for me neither:

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
        - matchExpressions:
            - key: "role.kubernetes.io/team"
              operator: "In"
              values:
                - "myrole"
            - key: "kubernetes.io/hostname"
              operator: "NotIn"
              values:
                - node_name_1
                - node_name_2

By "doesn't work" I mean that the first match (by role) works, but the nodes I'm trying to exclude get populated anyway.

Is this possible? If so, what am I doing wrong?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.