Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 22, 2022 12:53 pm GMT

How to use Scale-down Mode to delete/deallocate nodes in Azure Kubernetes Service

By default, scale-up operations performed manually or by the cluster autoscaler require the allocation and provisioning of new nodes, and scale-down operations delete nodes. Scale-down Mode allows us to decide whether we would like to delete or deallocate the nodes in our Azure Kubernetes Service (AKS) cluster upon scaling down.

When an Azure VM is in the Stopped (deallocated) state, we will not be charged for the VM compute resources. However, we'll still need to pay for any OS and data storage disks attached to the VM. This also means that the container images will be preserved on those nodes.

This behavior allows for faster operation speeds, as our deployment uses cached images. Scale-down Mode removes the need to pre-provision nodes and pre-pull container images, saving us compute cost.

Before we begin

Assuming that we have an existing AKS cluster. If we need an AKS cluster, see the AKS quick start using the Azure CLI, using Azure PowerShell, or using the Azure portal.

Using Scale-down Mode to deallocate nodes on scale-down

By setting --scale-down-mode Deallocate, nodes will be deallocated during a scale-down of our cluster/node pool. All deallocated nodes are stopped. When our cluster/node pool needs to scale up, the deallocated nodes will be started first before any new nodes are provisioned.

In this example, we create a new node pool with 20 nodes and specify that upon scale-down, nodes are to be deallocated via --scale-down-mode Deallocate.

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

By scaling the node pool and changing the node count to 5, we'll deallocate 15 nodes.

az aks nodepool scale --node-count 5 --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg

Deleting previously deallocated nodes

To delete our deallocated nodes, we can change our Scale-down Mode to Delete by setting --scale-down-mode Delete. The 15 deallocated nodes will now be deleted.

az aks nodepool update --scale-down-mode Delete --name kcdpool1 --cluster-name kcdAKSCluster --resource-group kcdrg

Using Scale-down Mode to delete nodes on scale-down

The default behavior of AKS without using Scale-down Mode is to delete your nodes when you scale-down your cluster. With Scale-down Mode, this behavior can be explicitly achieved by setting --scale-down-mode Delete.

In this example, we create a new node pool and specify that our nodes will be deleted upon scale-down via --scale-down-mode Delete. Scaling operations will be handled via the cluster autoscaler.

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.


Original Link: https://dev.to/kcdchennai/how-to-use-scale-down-mode-to-deletedeallocate-nodes-in-azure-kubernetes-service-33im

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To