How Kubernetes Horizontal Pod Autoscaler calculates CPU percentage?

8/2/2019

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?

-- AVarf
autoscaling
cpu
cpu-usage
kubernetes
scale

1 Answer

8/2/2019

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>.

-- Markus Dresch
Source: StackOverflow