Search code examples
kubernetesscheduling

Kubernetes : Pod scheduling/eviction relationship with requests/limits


If I have a node with 16 GB RAM and pods that have a memory request of 1GB and memory limit of 4GB, how many of these pods will be scheduled on the node? 4 or 16?

I would think it is 16 based on this https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/

The scheduler ensures that, for each resource type, the sum of the resource requests of the scheduled Containers is less than the capacity of the node.

And what if a pod starts using 4GB memory which is within its limits, will it be evicted? rescheduled?

I have a use case where my pods will typically use X memory but sometimes use 4X memory. How should I set my requests and limits for this case? Should I set the request to X or 4X?


Solution

  • Kubernetes scheduler should be able to schedule 16 pods each with 1GB memory requests to a node with free capacity of 16GB memory .If at any point in time any pod starts to use more memory(within limits) it will be allowed to do so. But the moment total memory consumption goes beyond the capacity of node then pods which are consuming above their requests will be randomly terminated and rescheduled unless there is a priority in which case lower priority pods will be be the victim.