Help Center> Cloud Container Engine> FAQ> Workload> Scheduling Policies> How Do I Prevent a Container on a Node from Being Evicted?

How Do I Prevent a Container on a Node from Being Evicted?

Context

Two containers on a node in a CCE cluster contend for resources with each other. As a result, kubelet evicts both the containers. This section describes how to set a policy to retain one of the containers.

Solution

kubelet uses the following criteria to evict a pod:

  • Quality of Service (QoS) class: BestEffort, Burstable, and Guaranteed
  • Consumed resources based on the pod scheduling request

Pods of different QoS classes are evicted in the following sequence:

BestEffort -> Burstable -> Guaranteed

  • Best-Effort pods: These pods will be treated as the lowest priority. They will be the first to be killed if the system runs out of memory.
  • Burstable pods: These pods will be killed if the system runs out of memory and no Best-Effort pods exist.
  • Guaranteed pods: These pods will be killed if the system runs out of memory and no Burstable or Best-Effort pods exist.

You can add the qosClass field to the YAML file of the workload to set the eviction priority, as shown in the following figure.

  • If processes in a pod are killed because of excessive resource usage than limited (while the node resources are still sufficient), the system tends to restart the container or create a pod.
  • If resources are sufficient, you can assign the QoS class of Guaranteed to all pods. In this way, more compute resources are used to improve service performance and stability, reducing troubleshooting time and costs.
  • To improve resource utilization, assign the QoS class of Guaranteed to service pods and Burstable or BestEffort to other pods (for example, filebeat).