Skip to content

Pod eviction and resource pressure

Pod eviction is the mechanism by which the kubelet reclaims resources on a node when the host is under pressure, such as CPU or memory starvation.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md] This process is critical for maintaining node stability and ensuring that critical workloads remain available during resource contention.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Resource Classification

Kubernetes categorizes resources based on how they handle contention.

  • Compressible resources (CPU): When these resources are scarce, Pods will experience throttling or "starvation" but will not be terminated.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]
  • Incompressible resources (Memory): When these resources are exhausted, the kernel will invoke the OOM (Out-Of-Memory) killer to terminate processes.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Quality of Service (QoS) Classes

Kubernetes uses QoS classes to determine the priority of Pods during the eviction process.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md] These classes are derived from the requests and limits defined in the Pod specification.

Guaranteed

A Pod is classified as Guaranteed if every container within it has both requests and limits set, and the values for CPU and memory are identical for each container.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Burstable

A Pod is classified as Burstable if it does not meet the criteria for Guaranteed, but at least one container has a specific resource request set.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

BestEffort

A Pod is classified as BestEffort if no requests or limits are set for any of its containers.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Eviction Priority

When a node faces resource pressure, the kubelet selects Pods for eviction based on their QoS class.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md] The order of priority, from most likely to be evicted to least likely, is:

  1. BestEffort
  2. Burstable
  3. Guaranteed^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Guaranteed Pods are granted the highest protection. They are only selected for eviction if they exceed their defined resource limits or if the host itself is in a severe Memory Pressure state.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Sources

  • 400-devops-06-kubernetes-k8s-paas-kubernetes.md