PhoneixS
PhoneixS

Reputation: 11016

What Kubernetes uses to calculate the CPU ratio, request or limit?

When you specify and Horizontal Pod Autoscaler in Kubernetes for example with targetCPUUtilizationPercentage of 50, what does Kubernetes use to calculate the CPU ratio, the request or the limit of the container?

So for example, with a request=250 and limit=500 and you want to scale up when is half its limit:

Upvotes: 5

Views: 3600

Answers (1)

P Ekambaram
P Ekambaram

Reputation: 17615

targetCPUUtilizationPercentage of 50 means that if average CPU utilization across all Pods goes up above 50% then HPA would scale up the deployment and if the average CPU utilization across all Pods goes below 50% then HPA would scale down the deployment if the number of replicas are more than 1

I just checked the code and found that targetUtilization percentage calculation uses resource request. refer below code

currentUtilization = int32((metricsTotal * 100) / requestsTotal)

here is the link https://github.com/kubernetes/kubernetes/blob/v1.9.0/pkg/controller/podautoscaler/metrics/utilization.go#L49

Upvotes: 7

Related Questions