Memory available in a node from the perspectives of Kubelet and the default OpenShift scheduler respectively
Environment
- Red Hat OpenShift Container Platform (RHOCP)
- 4
Issue
- When the default OpenShift scheduler has to select a node to host a pod, how does it calculate the available memory on the node? Is it taken into account the pod
requests, thelimitsor just the memory used? - If a node is running out of memory, Kubelet starts evicting pods. What does Kubelet consider available memory and used memory in this regard?
Resolution
Disclaimer: Links contained herein to external website(s) are provided for convenience only. Red Hat has not reviewed the links and is not responsible for the content or its availability. The inclusion of any link to an external website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.
To answer these questions, it must be first taken into account the concept of allocatable memory on OpenShift:
[Allocatable memory] = [Node Capacity] - [system-reserved] - [Hard-Eviction-Thresholds]
Refer to the following links for more details:
- Allocating resources for nodes in an OpenShift Container Platform cluster.
- Default values for the garbage collection related parameters on OCP4.
Default Scheduler
The default OpenShift scheduler considers that a node has enough available memory to host a new pod when the following is true:
[Memory request of the new pod] < [Allocatable memory] - [Total memory requested by all the pods currently running in the node]
- Note that both memory
limitsand memory usage are not taken into account for scheduling. Onlyrequestsare. - However, setting
requestslower than the amount of memory needed for a pod on purpose with the intention of making the pod allocation easier is not recommended. That may increase the pod density in an unhealthy way.
Kubelet
Nonetheless, Kubelet starts evicting pods when the memory used by all the ones running in the node is greater than the allocatable memory.
Warning:
active_filememory aka buffer/cache memory is considered memory used by Kubelet although it is available from a kernel perspective. Find additional information on the following link: active_file memory is not considered as available memory.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments