Moment For Technology

K8s scheduling and resource management

Posted on June 24, 2022, 1:26 a.m. by Sarah Stewart
Category: The back-end Tag: kubernetes

K8s resource model

Pod is the basic unit of K8S scheduling, and you can set resource limits for a POD.

When POD schedules, it schedules based on the values of Requests and resource limits based on the values of Limits. K8s sets pods to three QoS based on the requests and limits values of containers in pods:

  • Guaranteed: Requests and limits values must be set and equal.
  • Burstable: non-guaranteed, and at least one container in the Pod has memory or CPU requests set.
  • BestEffort: The container in pod has no requests and limits set

The purpose of the three QoS levels is how K8S selects and deletes pods when the host resources are insufficient. A POD that does not have any resource restrictions will be removed preferentially. That is, a POD whose priority is BestEffortBurstableGuaranteed will be removed preferentially.

K8s default scheduler

The scheduler works as follows:

Predicates algorithm Predicates algorithm is used to screen out the nodes that can run POD from numerous nodes, which can meet the following conditions:

  • The node resources meet the POD resource requirements
  • The host port number requested by pod is not used

Priorities algorithm The Priorities algorithm scores selected nodes, and PODS are scheduled to the nodes with the highest scores. The algorithm has different ideas as follows:

  • You can select the host with the most free resources
  • You can select a node with the most evenly distributed resources to avoid the situation that a node has a large amount of CPU allocated but a large amount of memory left
About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.