k8s HorizontalPodAutoscaler - set target on limit, not request

811 Views Asked by At

I have a deployment where cpu request is 500m and cpu limit is 1000m. I create a hpa as -

 metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 80

This makes calculations based on the cpu requests. Is there a way to make it look at the cpu limit instead ?

1

There are 1 best solutions below

1
On BEST ANSWER

If you set different values for limits and request, you made them "Burstable". What this means in Kubernetes is "This application is very important and may exceed it's normal targeted usage". You should set requests as normal limits and scale based on them. Actual limits provides infrastructure safety by limiting pod capabilities.

This is why you should start with setting requests and limits to same values. If you have problems with this(like pod startup requires little bit more than needed or scaling happens slowly) you should set bursting range but still think like requests as normal limits(More like soft limit/hard limit thing).

Answer is no, you can't. Because you're looking it wrong.