Kubernetes: What is the use of resource limit if we already have an HPA?

1.1k views Asked by At

Say I have resource requests and limits set to

resources:
  requests:
    cpu: "100m"
    memory: "512Mi"
  limits:
    cpu: "500m"
    memory: "1024Mi"

and targetCPUUtilizationPercentage set to 80,

so when more than 80m of CPU is utilized by pods on average, it will auto-scale.

So, what i want to understand is that the resource limit in this case will be useless, right? Or, does it play any role?

1

There are 1 answers

1
Justin Tamblyn On BEST ANSWER

As Zerkms has said the resource limit is per container.

Something else to note: the resource limit will be used for Kubernetes to evict pods and for assigning pods to nodes. For example if it is set to 1024Mi and it consumes 1100Mi, Kubernetes knows it may evict that pod.

If the HPA plus the current scaling metric criteria are met and Kubernetes is supposed to scale up the replicaset it will check the memory of the nodes and the memory requests of the pods before scheduling a pod for a node.