azure, kubernetes,

Scale AKS user node pool to 0

Sep 06, 2021 · 1 min read · Post a comment
Scale AKS user node pool to 0

In case you missed some of these posts:

In today’s post, we gonna see how can we be cost-effective, by scaling the User node pool to 0.

Prerequisites

  • Azure account
  • Azure CLI
  • Azure Kubernetes Service (AKS) cluster

Solution

Step 1. Open Terminal and login to Azure:

az login

Step 2. List the AKS cluster node pool (example):

az aks nodepool list --cluster-name devcoopsAKSCluster --resource-group devcoops --output table

Example output:

Name       OsType    VmSize           Count    MaxPods    ProvisioningState    Mode
---------  --------  ---------------  -------  ---------  -------------------  ------
nodepool1  Linux     Standard_DS2_v2  1        110        Succeeded            System
nodepool2  Linux     Standard_DS2_v2  1        110        Succeeded            User

Note:

  • nodepoll1 is the System node pool type and as the name says, is hosting the important system pods like CoreDNS.
  • nodepool2 is the User node pool and the main purpose is to host the application nodes.

Step 3. Scale the user node pool to 0:

az aks nodepool scale --name nodepool2 --cluster-name devcoopsAKSCluster --resource-group devcoops --node-count 0 

Step 4. Validate:

az aks nodepool list --cluster-name devcoopsAKSCluster --resource-group devcoops --output table

Example output:

Name       OsType    VmSize           Count    MaxPods    ProvisioningState    Mode
---------  --------  ---------------  -------  ---------  -------------------  ------
nodepool1  Linux     Standard_DS2_v2  1        110        Succeeded            System
nodepool2  Linux     Standard_DS2_v2  0        110        Succeeded            User

The User node pool instance count is successfully set to 0.

Conclusion

Although, you could host your application on the System node pool, it’s not recommended, and it’s not a good practice. If you want to further optimize your AKS costs, i suggest to Start and Stop AKS cluster.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on telegram.