By default, scale-up operations performed manually or by using the cluster autoscaler require the allocation and provisioning of new nodes, and scale-down operations delete nodes. Scale-down Mode approves us to determine whether we would like to delete or deallocate the nodes in our Azure Kubernetes Service (AKS) cluster upon scaling down.
We won't be charged for the compute resources of the stopped virtual machine. We need to pay for the OS and data storage disks that are attached to the VM. The container images will be preserved on those nodes.
Our deployment uses cached images and this behavior allows for faster operation speeds. The
scale-down mode eliminates the need for pre-provision and pre-pull images.
--scale-down-mode deallocate, we will be able to deallocate during a scale-down of our pool. The deallocated nodes are stopped. When the pool needs to scale up, the deallocated nodes will be the first to be started.
In this example, we create a new pool with 20 nodes and specify that upon scale-down, they will be dealt with via
az aks nodepool add --node-count 20 --scale-down-mode Deallocate --node-osdisk-type Managed --max-pods 10 --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
We will deallocate 15 nodes by scaling the pool and changing the count to 5.
az aks nodepool scale --node-count 5 --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
The Scale-down Mode to Delete can be changed by setting it. The 15 nodes will be deleted.
az aks nodepool update --scale-down-mode Delete --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg
When you scale-down your cluster, the default behavior of AKS is to remove your nodes. This behavior can be achieved by setting Scale-down Mode.
In this example, we create a new pool and specify that our nodes will be deleted upon scale-down. The cluster autoscaler will handle scaling operations.
az aks nodepool add --enable-cluster-autoscaler --min-count 1 --max-count 10 --max-pods 10 --node-osdisk-type Managed --scale-down-mode Delete --name kcdpool3 --cluster-name kcdAKSCluster --resource-group kcdrg
Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.