Azure Kubernetes Service

In the past I’ve scaled up a cluster to test a new deployment or to provide extra compute during an upgrade but when it comes to scaling down AKS won’t pick the node with less resources or even the drained one so I’ve seen it briefly disrupt a deployment.

To have more control on what AKS scales down you can use virtual machine scale set protection policies to specify which node to remove. Here’s how to do so…

I. Find the node you can to remove and drain it

kubectl drain aks-nodepool-1111111-vmss0001

You can verify after

Scheduling Disabled Node in Azure Kubernetes Service

II. Add the protection policy to all nodes except the drained one.

AKS Creates a VMSS for your K8S Nodes you can find AKS’s resource group under Settings –> Properties of your AKS

Protection Policy for Virtual Machine Scale Sets

III. Use AKS to scale down

Scale down an AKS Cluster

You will see the node/VM without protection getting removed.

IV. Remove the protection for future upgrades and to allow K8S to Orchestrate

Remove protection policy from Virtual Machine Scale Set