How to request scale up from 0 to X the number of nodes in a Nodepool in Azure Kubernetes using nodeSelector?

Viewed 33

I have a kubernetes cluster (v1.24.3) running in Azure with 3 nodepools called small, standard and large. For each of these nodepools I have added a label named type, where the value is SMALL-2CPU-8GB, STANDARD-4CPU-16GB and LARGE-8CPU-32GB respectively. These nodepools are also configured with the autoscaler from Azure, and the min is 0 and the max is 10.

Now, I am deploying my applications which are required to run in each of these nodepools depending on the specification - for example, one of the apps requires a small node, so it is requesting to run in the nodepool called small with a label type=SMALL-2CPU-8GB and so on.

The way I am requesting this is by setting the nodeSelector in the manifest of the application. Exactly this is the portion of the template:

# App 1
    podTemplate:
      spec:
        nodeSelector:
          type: LARGE-8CPU-32GB
          agentpool: large
# App 2
    podTemplate:
      spec:
        nodeSelector:
          type: STANDARD-4CPU-16GB
          agentpool: standard

# App 3
    podTemplate:
      spec:
        nodeSelector:
          type: SMALL-4CPU-16GB
          agentpool: small
...

When I apply the manifest to the cluster, the pods are in pending state with the message:

Normal   NotTriggerScaleUp       43m (x13 over 45m)     cluster-autoscaler       pod didn't trigger scale-up: 3 node(s) didn't match Pod's node affinity/selector, 1 not ready for scale-up

And I can see that the node count is still 0, so the pod is not triggering the autoscaler to request a new node.

My question is, how to make the autoscaler work when I am requesting nodes (even when the nodepool has zero nodes) via the nodeSelector? Should I specify a different label or use taints?

0 Answers
Related