Limiting cpu for a set of pods Limiting cpu for a set of pods kubernetes kubernetes

Limiting cpu for a set of pods


A good strategy here would be to play with both requests and limit parameter of resources.

As an example for your case, you can use following configuration

  • resources.requests.cpu - 750mC
  • resources.limits.cpu - 2000mC

This will allocate 3000m (740 x 4) CPU in the node, allowing additional 1000mC for CPU to burst.

Reference - https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/#motivation-for-cpu-requests-and-limits


My suggestion would be to enable pod auto scaling. There are 2 types of it:

  1. Horizontal Pod Autoscaler (HPA) - If your pods are identical and you do not require all 4 at once, then implement HPA for Pods. With this you can keep a minimum number of pods you require and then scale them to the maximum number you want based on metrics like CPU, Memory utilisation etc. HPA

  2. Vertical Pod Autoscaling (VPA) - You can implement VPA by utilizing the resource management provided by kubernetes. You can add parameter resources.requests.cpu to start your pod with and in case the utilisation increases you can limit it using parameter resources.limits.cpu. Resource management

Combination of both above methods will be ideal in your case.