Skip to Content
Asterrr's Handbook
4 · Cloud native architecture

Autoscaling

HPA, VPA, Cluster Autoscaler, Karpenter, KEDA and the Cluster Proportional Autoscaler. Which one scales Pods, which one resizes them, and which one adds nodes.

Exam tasks: 4.2 (cloud native ecosystem and principles: elastic scaling)

The decision: is the problem too few Pods, Pods that are the wrong size, or too few nodes, and what signal should drive the fix?

Elasticity is a cloud native property: capacity follows load without a person in the loop. Kubernetes splits it into three layers. Pod count and Pod size scale the workload. Node count scales the cluster underneath it.

yesyesno, queue or eventnoyesno, add nodesLoad changedScale Pod count?Driven by CPU or memory?HPAKEDA: event sourcesResize one Pod?VPACluster Autoscaler orKarpenter
Pick the autoscaler from what you need to scale.
15 s
Default HPA sync period.
5 min
Default scale-down stabilization window for the HPA.
1
Minimum replicas for a standard HPA. Scaling to zero needs KEDA or Knative.
Pending Pods
The trigger for Cluster Autoscaler and Karpenter.
AutoscalerScalesDriven byWhere it comes from
HPAReplicas of a Deployment or StatefulSetCPU and memory utilization, or custom and external metricsBuilt into Kubernetes (autoscaling/v2)
VPACPU and memory requests of PodsObserved usage historyAdd-on from the Kubernetes autoscaler project
Cluster AutoscalerNodes in node groupsPods stuck Pending for lack of capacity, and underused nodesAdd-on, works with cloud provider node groups
KarpenterNodes, picked to fit pending PodsPending Pods, consolidationKubernetes SIG Autoscaling subproject
Cluster Proportional AutoscalerReplicas of one add-on, such as CoreDNSNumber of nodes or cores in the cluster, by a linear or ladder formulaKubernetes autoscaler project add-on
KEDAReplicas, including to and from zeroEvent sources: queue depth, Kafka lag, cron, Prometheus queriesCNCF graduated project, drives an HPA under the hood
  • HPA utilization targets are a percentage of the Pod's requests. With no CPU request set, a CPU target has nothing to compare against.
  • HPA and VPA should not both act on the same CPU or memory metric for one workload; they fight each other.
  • Node autoscalers react to Pending Pods, not to high CPU on existing nodes. Pod autoscaling creates the Pods; node autoscaling makes room for them.
  • In-place Pod resize (changing a running container's CPU and memory without recreating the Pod) became stable in Kubernetes v1.35, which lets vertical scaling avoid restarts in many cases.

Exam signal

"Scale workers to zero when the queue is empty and back up when messages arrive" is KEDA. Plain HPA keeps at least one replica by default.

Two layers working together

Kubernetes clustermetricsyesnonew capacityHPA addsreplicasPods Pending: no roomNode autoscaleradds nodesPods RunningLoad rises
Pod autoscalers create Pods. When the Pods have no room, a node autoscaler adds nodes.
  • The HPA reads metrics through the metrics APIs. Without metrics-server, CPU-based scaling has no data.
  • The HPA scales up fast and scales down slowly. A stabilization window (five minutes by default) stops replica counts flapping when load wobbles.
  • The Cluster Proportional Autoscaler is a different idea. It sizes a single add-on, usually CoreDNS, in proportion to the cluster, so a 500-node cluster gets more DNS replicas than a 5-node one. It does not look at load.

Autoscalers are not interchangeable

HPA changes the number of Pods. VPA changes the size of each Pod. Cluster Autoscaler changes the number of nodes. A question that says "the Pods are Pending because no node has room" is never solved by HPA or VPA.

Scenarios

Scenario
An HPA at Quillfeather Analytics has scaled a Deployment to 30 replicas, but 8 Pods stay Pending with the message that no nodes have enough CPU. What adds capacity automatically?
Scenario
A media company runs a Deployment of thumbnail workers. They should drop to zero Pods when the job queue is empty and scale out as messages arrive. Which tool fits best?
Scenario
After a cluster grows from 10 to 400 nodes, DNS lookups slow down because CoreDNS still runs two replicas. Which component scales CoreDNS with the size of the cluster?

Further reading

On this page