question

ShreyasArani-1167 avatar image
0 Votes"
ShreyasArani-1167 asked srbose-msft answered

How to use cluster autoscaler with nodeSelector/node affinity

Hi I have gone through this link https://docs.microsoft.com/en-us/azure/aks/cluster-autoscaler for enabling autoscaling of node scaling using cluster autoscalar. My question is that I am having AKS cluster of 3 nodes and I have labelled the nodes manually and deployed the pods on the respective nodes. So when the autoscaling of node happens will the pods get deployed on this new node or will go in pending state?

Basically If I am using nodeSelector/node affinity then how to implement cluster autoscalar?

Any help or suggestions would be appreciated.

azure-kubernetes-service
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

srbose-msft avatar image
0 Votes"
srbose-msft answered

You can add labels to a node pool during node pool creation. Reference Labels set at the node pool are added to each node in the node pool. These labels are visible in Kubernetes for handling scheduling rules for nodes. Hence even if the node pool is autoscaled all nodes subsequently added will bear the same labels and hence pods with affinity or node selectors defined should not have any issues being scheduled.



Hope this helps.

Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShreyasArani-1167 avatar image
0 Votes"
ShreyasArani-1167 answered ShreyasArani-1167 edited

Hi @karishmatiwari-msft the cluster autoscaler watches for pods that can't be scheduled on nodes because of resource constraints. And then scales the node. But while deploying pods I have used node affinity so that pod get deploys on that particular. After the nodes get scaled the pod should get deployed on that newly scaled node. But how can I give the label of newly scaled node in the pod deployment file even before the node is scaled.

It would be helpful if you can send a working example.

Thanks in advance.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karishmatiwari-msft avatar image
0 Votes"
karishmatiwari-msft answered TF-1124 published

Does Cluster Autoscaler (CA) respect node affinity when selecting node groups to scale up?
CA respects nodeSelector and requiredDuringSchedulingIgnoredDuringExecution in nodeAffinity given that you have labelled your node groups accordingly. If there is a pod that cannot be scheduled with either nodeSelector or requiredDuringSchedulingIgnoredDuringExecution specified, CA will only consider node groups that satisfy those requirements for expansion.

However, CA does not consider "soft" constraints like preferredDuringSchedulingIgnoredDuringExecution when selecting node groups. That means that if CA has two or more node groups available for expansion, it will not use soft constraints to pick one node group over another.

You may find this FAQ on Cluster Autoscaler helpful. Let me know if you have further questions.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What does "given that you have labelled your node groups accordingly" mean? I have a matching tag on the ASG group but that doesn't appear to work.

0 Votes 0 ·