CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Application Developer

Manual Scaling and HorizontalPodAutoscaler

kubectl scale is one command and always works. An HPA is one command and often does nothing, because it needs two things people forget: a metrics-server, and CPU requests to calculate a percentage against. Both failure modes are reproduced here, then fixed, and then a load generator drives a real scale-up from one replica to the maximum.

Application Deployment Guide 22 of 44 Intermediate

--cpu-percent is deprecated and the captured output says so - the current flag is --cpu 50%. Note also that adding requests did not fix <unknown> immediately: it still read unknown 45 seconds later, because metrics-server scrapes on an interval and the Pods had just been recreated by the rollout.

Three schedulable workers, which the HPA needs - it scales to six replicas of a CPU-hungry Pod, and they have to fit somewhere.
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

This guide includes

Use this when replicas have to follow load rather than a number you typed. This matters because an HPA divides usage by the CPU request, so a Deployment that declares no requests gives it no denominator and it never scales anything at all.

Before you start

  1. Scaling by hand

  2. An HPA with no denominator

  3. Give it something to divide by

  4. Put it under load

  5. Taking the load away

Official sources