Appearance

HPA, VPA, and node autoscaling

Separate replica demand, per-Pod sizing and infrastructure capacity into interacting feedback loops.

What you will understand

  • Calculate a simple HPA recommendation from metrics and requests
  • Explain VPA recommendations and update risks
  • Predict when node autoscaling can and cannot place Pending Pods

Builds on: Kustomize and Helm

Mental model: three actuators solve three different shortages

The Horizontal Pod Autoscaler, or HPA, adjusts the desired replica count of a scalable workload using observed metrics. It adds more application instances, not more CPUs to an existing process or more worker nodes. Vertical Pod Autoscaler, or VPA, recommends or changes per-Pod resource requests according to its installed components and update policy. Node autoscaling changes infrastructure capacity through a provider integration. These loops can cooperate, but each has prerequisites and a different delay before useful capacity appears.

The HPA controller is part of Kubernetes control-plane operation. Its metrics pipeline is not automatically present: resource metrics commonly require Metrics Server, while custom and external metrics require appropriate adapters. VPA and node autoscalers are separately installed add-ons with their own permissions, configuration and implementation capabilities. A local kind cluster should not be assumed to acquire new physical machines when an HPA creates more Pods.

CPU utilization divides usage by request

Follow resource metrics through an HPA ratio recommendation into actual ready replicas.

Chart viewStep 1 of 4
Measure a defined utilizationCPU use is compared with the request, not the limit. Missing relevant requests can prevent this utilization metric from being defined.. API Pods, 4 replicas; average CPU 80% of request, active. Metrics pipeline, Resource metrics available, active. HPA, CPU target 50%; bounded replicas, idle. Deployment scale, Raw recommendation 7 replicas, idle. New Pods, Must schedule, start and become ready, idleAPI Pods: 4 replicas; average CPU 80% of request
API Pods4 replicas; average CPU 80% of requestIn focus
Metrics pipeline: Resource metrics available
Metrics pipelineResource metrics availableIn focus
HPA: CPU target 50%; bounded replicas
HPACPU target 50%; bounded replicasContext
Deployment scale: Raw recommendation 7 replicas
Deployment scaleRaw recommendation 7 replicasContext
New Pods: Must schedule, start and become ready
New PodsMust schedule, start and become readyContext
API Pods4 replicas; average CPU 80% of requestIn focus
Metrics pipelineResource metrics availableIn focus
HPACPU target 50%; bounded replicasContext
Deployment scaleRaw recommendation 7 replicasContext
New PodsMust schedule, start and become readyContext
Animation controls
Speed
0.5×
1×
2×
Explore a scenario
Normal behavior
Resource metrics are unavailable
Measure a defined utilization

CPU use is compared with the request, not the limit. Missing relevant requests can prevent this utilization metric from being defined.

Read the complete visual sequence
  1. Measure a defined utilization

    CPU use is compared with the request, not the limit. Missing relevant requests can prevent this utilization metric from being defined.

  2. Compute the simple ratio

    Four multiplied by 80/50 is 6.4, rounded up to seven before considering bounds and stabilization details.

  3. Write desired scale

    HPA updates the workload scale. That changes desired replicas but does not directly create worker capacity.

  4. Verify useful capacity

    The workload controller creates Pods, which must pass scheduling, startup and readiness before they serve requests.

Resource metrics are unavailable

The controller cannot obtain the expected CPU metric.

  1. Workload still exists

    The application can run while its autoscaling metrics path is absent or failing.

  2. HPA cannot evaluate demand

    Metric retrieval fails and conditions expose the problem; blindly increasing a limit does not install Metrics Server.

  3. Inspect the pipeline and requests

    Check metrics availability, HPA conditions and CPU requests, then verify a fresh observed value before testing scaling.

About this model

Simple homogeneous-Pod CPU example; real HPA includes tolerance, missing-metric and readiness handling.

Walkthrough: utilization has a denominator

For a simple CPU utilization target, HPA compares observed CPU use to requested CPU. A Pod using 200m with a 400m CPU request has 50 percent utilization by that measure, even if it has a 1 CPU limit. Requests are therefore both placement inputs and part of the autoscaling signal. Missing requests for relevant containers can make the corresponding utilization undefined. Missing metrics, unready Pods, stabilization rules and tolerances make real recommendations more conservative than a single algebraic expression.

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  minReplicas: 2
  maxReplicas: 8
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 60
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300

In the simplified ratio calculation, desired replicas equal the current replicas multiplied by observed utilization divided by target utilization, rounded up. Four replicas at 80 percent against a 50 percent target yield a raw recommendation of seven. Bounds and controller behavior still apply. This calculation is a model of proportional demand, not a throughput guarantee; CPU scaling cannot repair a serialized database lock or an exhausted external API quota.

Replicas, Pod size and nodes are different control decisions

Connect HPA demand, VPA sizing and an installed provider node autoscaler, including their interaction risks.

Scheduling viewStep 1 of 4
Increase replica demandHPA can create more desired Pods, but placement may fail if the existing workers lack room.. HPA, Changes replica demand, active. VPA, Recommends/updates requests, idle. Pending Pods, Need fitting node capacity, warning. Node autoscaler, Provider choices and limits, idle. New worker, Labels, resources, integrations, idle. Ready application, Actual useful serving capacity, idleHPA: Changes replica demand
HPAChanges replica demandIn focus
VPA: Recommends/updates requests
VPARecommends/updates requestsContext
Pending Pods: Need fitting node capacity
Pending PodsNeed fitting node capacityWarning
Node autoscaler: Provider choices and limits
Node autoscalerProvider choices and limitsContext
New worker: Labels, resources, integrations
New workerLabels, resources, integrationsContext
Ready application: Actual useful serving capacity
Ready applicationActual useful serving capacityContext
HPAChanges replica demandIn focus
VPARecommends/updates requestsContext
Pending PodsNeed fitting node capacityWarning
Node autoscalerProvider choices and limitsContext
New workerLabels, resources, integrationsContext
Ready applicationActual useful serving capacityContext
Animation controls
Speed
0.5×
1×
2×
Explore a scenario
Normal behavior
Hard affinity has no matching provider option
Increase replica demand

HPA can create more desired Pods, but placement may fail if the existing workers lack room.

Read the complete visual sequence
  1. Increase replica demand

    HPA can create more desired Pods, but placement may fail if the existing workers lack room.

  2. Size each Pod separately

    VPA changes or recommends requests. Those requests affect fit and can change CPU-utilization denominators used by HPA.

  3. Supply suitable infrastructure

    An installed node autoscaler evaluates whether provider capacity can satisfy the unschedulable Pods within configured limits.

  4. Wait for readiness

    The new node and its network/storage agents must work, then Pods must start and pass readiness before demand is actually served.

Hard affinity has no matching provider option

Adding generic nodes cannot satisfy the workload constraint.

  1. Pods request an unavailable label

    The workload requires a node attribute that no configured infrastructure option supplies.

  2. Autoscaler cannot make a fitting node

    Creating another generic worker would still fail the hard affinity rule, so this demand does not justify a viable node.

  3. Repair constraint or node offering

    Correct the workload requirement or configure a real matching node offering; increasing maxReplicas does not change satisfiability.

About this model

Optional VPA and node autoscaler are installed in this scenario; a plain local cluster need not have either.

Practice: watch all checkpoints, not just the desired count

kubectl top pods -n learning
kubectl apply -n learning -f api-hpa.yaml
kubectl get hpa api -n learning -w
kubectl describe hpa api -n learning
kubectl get deployment api -n learning
kubectl get pods -n learning -l app=api -o wide
kubectl get events -n learning --sort-by=.metadata.creationTimestamp

Use a bounded load generator only in the delivery and scaling lab, with explicit stop conditions. Expect <unknown> or metric-fetch errors if the required pipeline is absent. When desired replicas rise, check whether new Pods actually become scheduled and ready. Node startup, image pulls, application warm-up and downstream capacity can delay the useful result. A growing Pending count is a capacity or constraint signal, not proof that more replicas are already serving.

VPA recommendation-only operation can help evaluate sizing before allowing automated changes. An enabled update mechanism may recreate Pods or use supported in-place resizing paths depending on the installed version, policy and platform capabilities. Review disruption behavior and PDB interactions. Avoid using HPA CPU-utilization targets and VPA CPU-request changes together without a deliberate design: changing the request changes HPA’s denominator, potentially altering replica demand even when actual CPU use is unchanged.

Pitfalls: more nodes only help satisfiable demand

Node autoscalers evaluate unschedulable demand and available infrastructure choices. A new suitable node can resolve insufficient CPU, but it cannot fix a typo in required affinity if no offered node type can satisfy it. Cloud quota, maximum pool size, unavailable instance types, storage topology and PDB-constrained scale-down also matter. Scale-down must consider workload relocation and disruption, not just a low utilization chart. Set cost and capacity bounds, and verify that newly added nodes have the required labels, taints and network/storage integrations.

Check your understanding

HPA changes desired replicas from two to six, but four Pods remain Pending. Has horizontal scaling finished?

No. Replica demand increased, but useful serving capacity has not reached six. Inspect scheduling events, requests, affinity and storage constraints, then determine whether an installed node autoscaler can supply suitable nodes. The Deployment replica count is an intermediate control signal; readiness and actual application throughput establish the outcome.

Next, coordinate these loops with safe release configuration so that delivery does not repeatedly overwrite autoscaler decisions or consume all available rollout headroom.

Primary documentation

Go to the source

Reviewed 2026-10-27 · Kubernetes 1.37 · Related local exercise

Search the book

Search loads when you open it.