Autoscaler in Azure Kubernetes Service (AKS) Cluster

Autoscaler in Azure Kubernetes Service (AKS) Cluster

To adjust with application demands, such as between the working hours and non-working hours or in weekdays and weekend, clusters often need a way to automatically scale. 


AKS clusters can be scaled in one of two ways:

Cluster Autoscaler

The cluster Autoscaler watches for pods that can't be scheduled on nodes because of resource constraints. The cluster then automatically increases the number of nodes.

Horizontal Pod autoscaler

The horizontal pod autoscaler uses the Metrics Server in a Kubernetes cluster to monitor the resource demand of pods. If an application needs more resources, the number of pods is automatically increased to meet the demand.

Reference: docs.microsoft.com


Both the cluster autoscaler and horizontal pod autoscaler can also decrease the number of nodes and pods as needed.


Create an AKS cluster and enable the cluster autoscaler

We can enable cluster autoscaler either through Azure Portal or Azure CLI.


If you need to create an AKS cluster, we can use the "az aks create" command. 

To enable and configure the cluster autoscaler on the node pool for the cluster, use the --enable-cluster-autoscaler parameter, and specify a node --min-count and --max-count.

For example

An AKS cluster with a single node pool backed by a virtual machine scale set. It also enables the cluster autoscaler on the node pool for the cluster and sets a minimum of 1 and maximum of 3 nodes:

 


Update an existing AKS cluster to enable the cluster autoscaler

We can use "az aks update" command to enable and configure the cluster autoscaler on the node pool for the existing cluster.

We need to use "--enable-cluster-autoscaler" parameter, and need to specify a node --min-count and --max-count.

 

Change the cluster autoscaler settings

 


Disable the cluster autoscaler

To disable cluster autoscaler, we need to use "--disable-cluster-autoscaler" parameter.

 

Use the cluster autoscaler with multiple node pools enabled

The cluster autoscaler can be used together with multiple node pools enabled. 

 

The cluster autoscaler can be disabled with "az aks nodepool update" and passing the --disable-cluster-autoscaler parameter.

 


Stay Tuned for more latest Content!


Comments

Popular posts from this blog

Free Courses - Git & GitHub (DevOps)

6 FREE courses to learn AWS & AWS DevOps (Concepts + Hands-on + Interview)