Skip to main content
Running workloadsLesson 8 of 14

Scaling with Load (HPA)

A service that normally runs fine on two Pods suddenly gets a flood of requests. Follow how the HPA (Horizontal Pod Autoscaler) notices and adds Pods.

Avg CPU usage40%
Current Pods2
Desired Pods2
node-1node-2User trafficrequestsweb-1CPUweb-2CPUweb-3new Podweb-4new Podmetrics-servercollects usageHPAtarget CPU 60%DeploymentreplicasSchedulerpicks a node
RequestResponse / reportAppears in a later step

What you will learn

  • Where usage is measured and how it reaches the HPA
  • How the HPA calculates the desired Pod count
  • The HPA only changes the count; the scheduler does placement
  • Scaling stops at Pending when nodes run out of room
  • Why scale-in is deliberately slow

When the HPA does not behave as expected​

SymptomWhat to check
Usage shows as <unknown>Whether metrics-server is running, and whether the Pods declare resource requests
Desired Pods went up but the Pod is PendingFree resources on nodes, namespace quota
Load dropped but Pods stayWhether the scale-in stabilization window has passed, the minimum replica count

Try it yourself​

kubectl top pods # Per-Pod usage metrics-server collected
kubectl get hpa -A # Target vs current usage, current Pod count
kubectl describe hpa <name> # Scaling events and conditions
kubectl get pods -A --field-selector=status.phase=Pending # Pods stuck for lack of node room

Check yourself

  1. An HPA targets 60% average CPU. 2 pods are running at 90%. How many pods does it want?
  2. kubectl get hpa shows the desired count went up, but the new pod stays Pending. What is most likely?
  3. The HPA shows usage as <unknown>. What should you check?

Further reading: Horizontal Pod Autoscaling · HPA Walkthrough