Skip to main content
RunBook Academy

KubernetesLXXXI · Cluster Autoscaling ConceptsCluster autoscaling

Cluster Autoscaler — the cluster-level scaler

Advanced⏱ ~14 minkubectlcluster-autoscaler

What you'll learn

  • Explain what the Cluster Autoscaler does
  • Identify the relationship between Cluster Autoscaler and HPA
  • Recognize the cloud-provider integrations
  • Use Cluster Autoscaler to scale the cluster

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

The Cluster Autoscaler is the cluster-level scaler. It adjusts the number of worker nodes in the cluster based on unschedulable pods. The Horizontal Pod Autoscaler (HPA) adjusts the number of pod replicas; the Cluster Autoscaler adjusts the number of nodes. This lesson walks the Cluster Autoscaler, the cloud-provider integrations, and the relationship with HPA.

What the Cluster Autoscaler does

The Cluster Autoscaler is a controller that runs as a Deployment in the cluster. It monitors the API server for unschedulable pods and adjusts the node count to satisfy the demand.

flowchart LR
    A[New pod] --> B{Schedulable?}
    B -->|no| C[Unschedulable pod]
    C --> D[Cluster Autoscaler]
    D --> E[Scale up node group]
    E --> F[New node joins]
    F --> G[Pod scheduled]
    G --> H[Cluster Autoscaler monitors]
    H --> I{Underutilized?}
    I -->|yes| J[Scale down node group]
    J --> K[Node drained and terminated]

The autoscaler runs a reconciliation loop every 10 seconds (by default). It checks for unschedulable pods and adjusts the node count.

The cluster-autoscaler Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cluster-autoscaler
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cluster-autoscaler
  template:
    metadata:
      labels:
        app: cluster-autoscaler
    spec:
      containers:
      - name: cluster-autoscaler
        image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.34.x
        command:
        - ./cluster-autoscaler
        - --v=4
        - --stderrthreshold=info
        - --cloud-provider=aws
        - --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled,k8s.io/cluster-autoscaler/cluster-name=my-cluster
        - --balance-similar-node-groups
        - --skip-nodes-with-local-storage=false
        - --expander=least-waste
        - --scale-down-enabled=true
        - --scale-down-delay-after-add=10m
        - --scale-down-unneeded-time=10m

The deployment is a single replica. The cluster autoscaler uses a leader election to ensure only one instance is active.

The cloud-provider integrations

The Cluster Autoscaler supports multiple cloud providers:

CloudMechanism
AWSAuto Scaling Groups (ASG)
GCPManaged Instance Groups (MIG)
AzureVirtual Machine Scale Sets (VMSS)
OpenStackServer Groups
DigitalOceanDroplet Pools
AlibabaESS

The cloud provider is configured via --cloud-provider flag and the corresponding node-group discovery.

flowchart LR
    A[Cluster Autoscaler] --> B[AWS ASG]
    A --> C[GCP MIG]
    A --> D[Azure VMSS]
    A --> E[OpenStack Server Groups]

The scale-up

The scale-up is triggered by unschedulable pods:

Pod: nginx-1-abc
Status: Pending
Reason: Unschedulable
Message: 0/5 nodes are available: 5 Insufficient cpu

The Cluster Autoscaler detects the unschedulable pod and launches a new node:

cluster-autoscaler: pod nginx-1-abc is unschedulable, scaling up node group workers
cluster-autoscaler: launching new node in ASG workers
cluster-autoscaler: node worker-6 joined the cluster

The new node joins the cluster; the pod is scheduled.

The scale-down

The scale-down is triggered by underutilized nodes:

Node: worker-3
CPU utilization: 10%
Memory utilization: 15%

The Cluster Autoscaler detects the underutilized node and drains it:

cluster-autoscaler: node worker-3 is underutilized, scaling down
cluster-autoscaler: draining node worker-3
cluster-autoscaler: terminating node worker-3

The node is drained; the pods are rescheduled; the node is terminated.

The relationship with HPA

The two autoscalers are complementary:

flowchart LR
    A[CPU > 80%] --> B[HPA]
    B --> C[Scale up pods]
    C --> D[Pod unschedulable]
    D --> E[Cluster Autoscaler]
    E --> F[Scale up nodes]
    F --> G[Pod scheduled]

The HPA reacts to per-pod metrics (CPU, memory). The Cluster Autoscaler reacts to cluster-level metrics (node utilization).

HPA: scale pods based on per-pod metrics
Cluster Autoscaler: scale nodes based on cluster metrics

The cluster-autoscaler metrics

The Cluster Autoscaler exposes metrics:

cluster_autoscaler_nodes_count
cluster_autoscaler_unschedulable_pods_count
cluster_autoscaler_node_group_size
cluster_autoscaler_scaleup_operations_total
cluster_autoscaler_scaledown_operations_total

The metrics are scraped by Prometheus and used for alerting.

The cost optimization

The Cluster Autoscaler is a cost optimization tool:

  • Scale down idle nodes. Saves money on cloud bills.
  • Scale up to meet demand. Maintains availability.
  • Balance node groups. Distributes load across node groups.

The cost savings depend on the workload pattern. A cluster with steady load saves less; a cluster with bursty load saves more.

Cross-course references

  • The Observability course covers autoscaler metrics.
  • The Terraform course covers IaC-managed node groups.
  • The AWS course covers ASG scaling.

Quiz

Knowledge check · 4 questions

  1. Q1. What is the relationship between the Cluster Autoscaler and the HPA?

  2. Q2. The Cluster Autoscaler scales up when there are unschedulable pods.

  3. Q3. Walk the scale-up flow when a Deployment scales its replicas and the cluster runs out of capacity.

    5-worker cluster. Nginx Deployment replicas increased from 3 to 20. The cluster has 5 nodes; the new pods are unschedulable. Cluster Autoscaler is configured.

  4. Q4. What triggers the Cluster Autoscaler to scale down a node?

Passing score: 75%. Answers are checked in this browser.

Production discipline

  • Configure Cluster Autoscaler with the cloud provider. AWS ASG, GCP MIG, Azure VMSS.
  • Set the min/max node count. Bound the cluster size.
  • Monitor the autoscaler metrics. Prometheus exposes them.
  • Test the scale-up and scale-down. Catch the issues before production.
  • Document the autoscaler config. The cloud provider, the node groups, the bounds.
  • Use the scale-down delay. Avoid thrashing from brief load drops.

The Cluster Autoscaler is the cluster’s cost optimization. Operating it well is configuring the node groups, monitoring the metrics, and tuning the delays.