An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
Hello @Varma
If the AKS cluster autoscaler isn’t enabled yet, you’ll first need to enable it. Then, you can deploy a workload that creates unschedulable pods to trigger scaling. This way you can test it out better way.
Step 1: Enable the Cluster Autoscaler (see below for sample Azure cli command)
az aks nodepool update \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name nodepool1 \
--enable-cluster-autoscaler \
--min-count 1 \
--max-count 5
This allows AKS to scale the node pool automatically between 1 and 5 nodes, depending on scheduling needs.
Verify Autoscaler Settings
Instead of listing node pools, use this command to confirm autoscaler configuration:
az aks nodepool show \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name nodepool1 \
--query "{autoscalerEnabled:enableAutoScaling,min:minCount,max:maxCount}" \
--output table
This reliably shows whether autoscaling is enabled and the configured limits.
Step 2: Deploy a Workload with Resource Requests
The cluster autoscaler reacts to resource requests, not actual CPU or memory usage. So defining requests is essential.
Example deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
resources:
requests:
cpu: "500m"
memory: "512Mi"
Apply it:
kubectl apply -f nginx-deployment.yaml
Step3: Trigger Scale up
Increase the number of replicas beyond the current node capacity:
kubectl scale deployment nginx-deployment --replicas=15
Some pods should move into a Pending state due to insufficient resources:
kubectl get pods
When unschedulable pods are detected, the cluster autoscaler will automatically add nodes (within the defined min/max range).
Step 4: Observe Scaling Activity
You can monitor the behavior using:
Watch nodes in real time:
kubectl get nodes -w
Check cluster events:
kubectl get events
Or review scaling activity in the Azure Portal under: AKS -> Node pools
Step 5: Test Scale-Down
Reduce replicas using:-
kubectl scale deployment nginx-deployment --replicas=1
After nodes remain underutilized for a period of time, the autoscaler will gradually remove extra nodes down to the configured minimum.
References:
- https://learn.microsoft.com/en-us/azure/aks/cluster-autoscaler-overview
- https://learn.microsoft.com/en-us/azure/aks/cluster-autoscaler?tabs=azure-cli
If there are any follow-up queries here or if you run into any failures while trying the above commands, just let me know in the comments and I'll be happy to help you out further.
If this helped to clarify your query, please don't forget to click on "Accept Answer" button.
Accept Answer button would look something like below: