Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Kubernetes Horizontal Pod Autoscaler calculates CPU percentage?

I set up my cluster and I want my deployments to scale up when the first pod uses 75% of one cpu (core). I did this with hpa and everything is working but I noticed that the hpa percentage is strange.

Based on what I know 1 cpu = 1000 milliunits and what I see in kubectl top pods is pod-A using 9m but what I see in kubectl get hpa is pod-A 9%/75% which doesn't make sense, 9% of 1000 is 90 and not 9. I want to know how hpa is calculating the percentage and how shall I configure it so when I reach 75% of one cpu it scales up?

like image 297
AVarf Avatar asked Jan 20 '26 06:01

AVarf


1 Answers

To the horizontal pod autoscaler 100% of a metric (cpu or memory) is the amount set in resource requests. So if you pod requests 100m cpu, 9m is 9% and it would scale out on 75m.

Double check if you really have requested 1 (or 1000m) cpu by issuing kubectl describe pod <pod-name>.

like image 134
Markus Dresch Avatar answered Jan 23 '26 21:01

Markus Dresch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!