Matthias M
Matthias M

Reputation: 14930

Kubernetes: Affinity depending on Azure Availability Set

Requirement

Kubernetes in Azure uses Availability Sets as the default availability strategy.

I can specify the kubernetes nodeSelector attribute to select a specific node.

kind: Pod
... 
spec:
  ...   
  nodeSelector:
    ???

Question

Can I specify the nodeSelector rule to use a node in a specific Availability Set?

I could label the pods manually after creation. But is there an automatic solution?

Upvotes: 1

Views: 925

Answers (2)

Matthias M
Matthias M

Reputation: 14930

4c74356b41 was right. It does not make sense to use availability sets in my pod affinity rules as an availability strategy.

But I solved my problem by using availability zones for my affinity rules:

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: topology.kubernetes.io/zone
            operator: In
            values:
            - westeurope-1

Upvotes: 1

4c74356b41
4c74356b41

Reputation: 72181

first of all, this question makes no sense, as with availability sets you can only have 1 node pool with AKS (and your tags mention AKS) (at least supported). but still, nodes have labels that look like this:

agentpool=pool_name

so your node selector would looks like this:

  nodeSelector:
    agentpool: pool_name

Upvotes: 4

Related Questions