Fairly new to kubernetes, I have a question about setting limits
and requests
in regards to CPU
and Memory
. If I have a few applications in my cluster but none of these applications are in production how do I determine the correct way to set the limits
and requests
for the applications in the cluster with know prior data.
I tried the kubectl top pods -n <namespace>
but this only gave me the current usage, wondering if anyone had any suggestions of a logical way to set the limits
and requests
?
CodePudding user response:
To determine request and limits, you can try the vertical pod autoscaler : https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler
You have two main modes :
off
: give informations about request and limits during the pod life.recreate
: recreate the pod with new request and limits (when needed)
CodePudding user response:
Suppose you executed kubectl top -n namespace and found pod is consuming 50m CPU and 230MB of memory. (Assuming the pod is running in a development/staging environment and it's idle - not processing any requests) you can use this data in requests as this is the minimum amount of resource which is required to run this pod, If had to set request I would have set 50m CPU and 256MB of Memory.
To set limits you should ask a tester to make 100 requests and meanwhile watch ⌚ load using kubectl top command (Suppose you saw pod is consuming 170m CPU and 400MB memory) Now subtract it with idle pod resources.
170m - 50m = 120m 400MB - 230MB = 170MB
120m CPU and 170MB of Memory are required to serve 100 requests.
Now as per your requirements you can set limits.
For more information visit https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/