Azure AKS: Control which node should be removed while downscaling

7/18/2019

I have an AKS-Cluster in Azure. When I scale down the cluster with az aks scale for example I want to control which Node should be removed.

I cannot find a documentation that describes how Azure decides. Will Azure prefer removing nodes that are already cordoned or drained?

Deleting it from the Azure Portal is not an option, because I want an application to communicate with Azure via CLI or API.

-- Marc_craM
azure
azure-aks
kubernetes
scaling

1 Answer

7/19/2019

First of all, it's impossible to control which node to remove when you scale down the AKS cluster. Then I will show you how do the nodes change when you scale the AKS cluster.

When you do not use the VMSS as the agent pool, it means the AKS cluster use the individual VMs as the nodes. If you scale up, then it will increase the nodes with the index after the existing nodes. For example, the cluster has one node with the index 0 and then it will use the index 1 if you scale up one node. And if you scale down, it will remove the nodes with the biggest index in the sequence at first.

When you use the VMSS as the agent pool, it will comply with the scale rules of VMSS. And you can see the VMSS scale rules in the changes of VMSS scale up and down.

Also, you can take a look at the Azure CLI command az aks scale that scale the AKS cluster and the REST API.

-- Charles Xu
Source: StackOverflow