CertGrid CertGrid
Concepts·Kubernetes and Cloud Native Associate

HPA, VPA and Cluster Autoscaler

HPA adds Pods, VPA resizes them, Cluster Autoscaler adds nodes. Only one of the three ships with Kubernetes, and confusing them is why "we have autoscaling" so often means "Pods pile up Pending".

Cloud Native Architecture Guide 31 of 46 Beginner

Written against the versions above. The interfaces below are versioned standards and change slowly; the implementations plugged into them change constantly. That is the point of them.

A four-node kubeadm cluster with Calico for CNI and two CSI drivers installed.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. What is installed, and what is not

    Three autoscalers, three different jobs:

    • HPA - more replicas of the same Pod. Built in, an API object, needs a metrics source.
    • VPA - the same replica count, with bigger or smaller requests. Not built in. A separate project.
    • Cluster Autoscaler - more nodes. Not built in, and it needs to talk to whatever provides your machines, so on bare metal there is usually nothing for it to call.

    On this cluster: neither VPA nor Cluster Autoscaler exists. That is the normal state of a kubeadm cluster, and it has a direct consequence - if every node is full, an HPA scaling from 2 to 10 produces eight Pending Pods and no extra capacity. The HPA did its job; nothing was listening for the result.

    bash Example session
    kubectl --context cka1001 get deploy -A | grep -i -E 'cluster-autoscaler|vpa' || echo "no cluster-autoscaler and no VPA on this cluster"no cluster-autoscaler and no VPA on this cluster

    Expected resultConfirmation that neither is running.

    Success conditionYou know which autoscalers your cluster actually has.

  2. The metrics APIs, and which ones exist

    Autoscaling reads metrics through aggregated APIs, and there are three:

    • metrics.k8s.io - CPU and memory, served by metrics-server. Present here.
    • custom.metrics.k8s.io - anything from your own monitoring, usually via the Prometheus Adapter. Absent.
    • external.metrics.k8s.io - metrics from outside the cluster entirely, like a queue depth. Absent.

    Only the first is listed, which bounds what an HPA here can do: CPU and memory only. "Scale on requests per second" needs the second API, and installing it is a separate project decision - not a flag.

    bash Example session
    kubectl --context cka1001 get apiservices | grep -E 'metrics|custom.metrics|external.metrics'v1beta1.metrics.k8s.io                 kube-system/metrics-server   True        14h

    Expected resultJust v1beta1.metrics.k8s.io, Available and backed by metrics-server.

    Success conditionYou can say which metric families are available to an HPA on this cluster.

Troubleshooting

Official sources