BM: Baca dalam Bahasa Melayu
World K5: Lunch Rush
Scale out at lunch rush: HPA
You will learn: how an HPA adds trays when they get busy, and removes them later.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
At noon the queue triples. At 3 pm the food court is empty. How many trays do you want?
Pick one answer.
Watch
kind-dev namespace defaultA HorizontalPodAutoscaler (HPA): A helper manager who adds trays when they get busy and removes them when it is quiet. (HPA) is a helper manager. It checks every 15 seconds how busy the trays are. Busy? It orders more. Lunch took this shop from 3 to 10.
Predict
“Busy” means CPU use as a share of each tray’s request. The target is 50%. Now 3 trays run at 100%. How many trays does the HPA want?
Pick one answer.
Try it
An HPA is YAML too. This one will not apply. Read kubectl’s error, then fix the one line.
Fix the manifest, then press Apply.
Try it
Now do it with one command. Make the HPA, then press Lunch rush. Watch the trays grow.
kubectl autoscale deployment shop --cpu=50% --min=3 --max=10kind-dev namespace defaultshop3/3 ready
dev-control-planeOpenManagerNo trays here.
dev-workerOpen- shop·6l2p4
dev-worker2Open- shop·5gkrw
- shop·nlvkf
Hint
Make the HPA first. Then press Lunch rush and let the clock run.Watch
kind-dev namespace defaultcpu: <unknown>/50% means: these trays have no CPU request. Without a request, “50% busy” has no meaning. Add resources.requests.cpu to the container.
Predict
Lunch ends. CPU drops to 5%. When do the extra trays go away?
Pick one answer.
You did it!
You can now let an HPA add and remove trays for you.
Go deeper (optional)
Scaling down waits 5 minutes by default. Scaling up may double, or add 4 trays, per 15 seconds. Tune both with behavior in the YAML. In Kubernetes 1.37, minReplicas: 0 (scale to zero) is beta and on by default. It needs an object or external metric, not CPU.
Real rep (optional): try the HPA walkthrough on kubernetes.io. Use a throwaway kind cluster.
Bahasa Melayu
Pukul 12 tengah hari, barisan jadi tiga kali ganda. Pukul 3 petang, medan selera kosong. Berapa pod (dulang) yang anda mahu?
HorizontalPodAutoscaler (HPA) ialah pembantu pengurus. Setiap 15 saat ia semak betapa sibuk pod. Sibuk? Ia pesan lagi. Waktu makan bawa kedai ini dari 3 ke 10.
“Sibuk” maksudnya guna CPU berbanding request setiap pod. Sasaran 50%. Sekarang 3 pod berjalan pada 100%. Berapa pod yang HPA mahu?
HPA juga YAML. Yang ini tak boleh di-apply. Baca ralat kubectl, kemudian baiki satu baris itu.
Sekarang buat dengan satu arahan. Cipta HPA, kemudian tekan Waktu makan tengah hari. Lihat pod bertambah.
kubectl autoscale deployment shop --cpu=50% --min=3 --max=10cpu: <unknown>/50% maksudnya: pod ini tiada request CPU. Tanpa request, “50% sibuk” tiada makna. Tambah resources.requests.cpu pada container.
Waktu makan habis. CPU turun ke 5%. Bila pod tambahan hilang?
Kini anda boleh biar HPA tambah dan buang pod untuk anda.
You finished this before. Practice is always welcome!
Official docs: Kubernetes: Horizontal Pod Autoscaling · Kubernetes: HPA walkthrough · kubectl autoscale
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?