Scale nodes: cluster autoscaler and Karpenter
In this task you'll choose how a cluster adds and removes nodes.
Pod autoscalers (HPA, KEDA) add pods. When those pods don't fit, something must add nodes. The cluster autoscaler grows and shrinks your existing node pools, within limits you set, when pods are Pending or nodes sit nearly empty.
Karpenter works differently: it looks at the Pending pods and creates nodes of whatever size and type fits them best, then removes or replaces nodes to pack work tightly (consolidation). On AKS it's offered as Node Auto Provisioning (NAP). KEDA and Karpenter aren't rivals: KEDA scales pods on events, Karpenter supplies the nodes.
Example. Tollmere Logistics' nightly route planning needed large-memory nodes for 2 hours. With fixed node pools they paid for big nodes all day. With Node Auto Provisioning, big nodes appear when the jobs start and are removed when they finish.
Before you start
You need: Nothing. Time: 20 minutes.
Where to look
- AKS cluster
- Settings
- Node pools
Steps
- List what scales pods (HPA, KEDA) and what scales nodes in your cluster.
- If pods sit Pending with 'Insufficient cpu' or 'Insufficient memory', you need node scaling, not pod scaling.
- Choose the cluster autoscaler for predictable pools, or Node Auto Provisioning for varied workloads.
- Always set minimum and maximum limits, so autoscaling can't run up an unlimited bill.
Commands
# Turn on the cluster autoscaler for an AKS node pool
az aks nodepool update -g <group> --cluster-name <cluster> -n <pool> --enable-cluster-autoscaler --min-count 1 --max-count 5
Watch out for
- Cost
- Node autoscaling saves money when demand drops, and spends it when it rises: always set a maximum.
- Security
- New nodes must come from approved images and sizes; restrict them in the configuration.
- Common mistakes
- Scaling pods with nowhere to put them, and missing disruption budgets, so consolidation interrupts apps.
Clean up
Nothing to clean up.
Words to know
- Cluster autoscaler
- Adds or removes nodes in existing node pools when pods can't be placed or nodes are underused.
- Karpenter
- A node autoscaler that creates right-sized nodes for Pending pods and consolidates them.
- Node Auto Provisioning
- AKS's managed Karpenter feature.
- Consolidation
- Moving pods onto fewer, cheaper nodes and removing the rest.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On