0
0
Azurecloud~5 mins

Node pools and scaling in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you run applications in the cloud, you need computers to run them. Node pools let you group these computers with similar settings. Scaling means adding or removing these computers automatically to handle more or less work.
When your app needs more computers during busy times and fewer when quiet to save money
When you want to separate computers by type, like some with more memory and some with more CPU
When you want to update or fix some computers without stopping the whole app
When you want to run different versions of your app on different groups of computers
When you want to control costs by only running the number of computers you need
Config File - nodepool-scale.yaml
nodepool-scale.yaml
apiVersion: azure.microsoft.com/v1
kind: NodePool
metadata:
  name: example-nodepool
  resourceGroup: example-resource-group
spec:
  clusterName: example-aks-cluster
  vmSize: Standard_DS2_v2
  nodeCount: 3
  enableAutoScaling: true
  minCount: 2
  maxCount: 5

This file defines a node pool for an Azure Kubernetes Service (AKS) cluster.

vmSize sets the computer size.

nodeCount is the starting number of computers.

enableAutoScaling turns on automatic scaling.

minCount and maxCount set the limits for scaling.

Commands
This command creates a new node pool named example-nodepool in the AKS cluster example-aks-cluster with 3 nodes. It enables automatic scaling between 2 and 5 nodes with a specific VM size.
Terminal
az aks nodepool add --resource-group example-resource-group --cluster-name example-aks-cluster --name example-nodepool --node-count 3 --enable-cluster-autoscaler --min-count 2 --max-count 5 --node-vm-size Standard_DS2_v2
Expected OutputExpected
Operation "Create" started for node pool example-nodepool Succeeded
--node-count - Sets the initial number of nodes
--enable-cluster-autoscaler - Turns on automatic scaling
--min-count - Minimum number of nodes when scaling
This command lists all node pools in the AKS cluster to verify the new node pool was created and check its status.
Terminal
az aks nodepool list --resource-group example-resource-group --cluster-name example-aks-cluster
Expected OutputExpected
[ { "name": "example-nodepool", "count": 3, "vmSize": "Standard_DS2_v2", "enableAutoScaling": true, "minCount": 2, "maxCount": 5 } ]
This command manually scales the example-nodepool to 4 nodes if you want to increase capacity immediately.
Terminal
az aks nodepool scale --resource-group example-resource-group --cluster-name example-aks-cluster --name example-nodepool --node-count 4
Expected OutputExpected
Operation "Scale" started for node pool example-nodepool Succeeded
--node-count - Sets the desired number of nodes
This command shows detailed information about the example-nodepool to confirm the current number of nodes and scaling settings.
Terminal
az aks nodepool show --resource-group example-resource-group --cluster-name example-aks-cluster --name example-nodepool
Expected OutputExpected
{ "name": "example-nodepool", "count": 4, "vmSize": "Standard_DS2_v2", "enableAutoScaling": true, "minCount": 2, "maxCount": 5 }
Key Concept

If you remember nothing else from this pattern, remember: node pools group similar computers and scaling adjusts their number automatically to match your app's needs.

Common Mistakes
Not enabling autoscaling when creating the node pool
The node pool will not adjust size automatically, causing wasted resources or lack of capacity
Always use --enable-cluster-autoscaler with min and max counts to allow scaling
Setting minCount higher than maxCount
This causes configuration errors and prevents scaling from working
Ensure minCount is less than or equal to maxCount
Scaling node pool manually without checking autoscaling settings
Autoscaler may override manual changes or cause conflicts
Check if autoscaling is enabled before manual scaling; disable autoscaling if manual control is needed
Summary
Create a node pool with az aks nodepool add to group similar computers.
Enable autoscaling with min and max counts to adjust node numbers automatically.
Use az aks nodepool list and show to check node pool status and settings.
Scale manually with az aks nodepool scale only if autoscaling is off or needs override.