Node-pressure Eviction

A Node starts running out of memory or disk space, and its Pods begin to stop one by one, though nobody deleted them. Who decides which of them go first, and why do some of them survive to the very end?

Play the animation 5 steps, animated, plays on a computer or a tablet

Node-pressure Eviction, Kubernetes diagram

Node-pressure Eviction, step by step

  1. Kubelet derives memory.available from cAdvisor stats as capacity minus the working set, and it has dropped to 500Mi. The eviction manager polls these stats every 10s, compares them against the --eviction-hard thresholds and finds one breached.

    Play from step 1
  2. Kubelet PATCHes Node.status.conditions: MemoryPressure flips from False to True. The control plane turns this into a NoSchedule taint (node.kubernetes.io/memory-pressure), so Pods that do not tolerate it can no longer be scheduled here. Being Burstable or Guaranteed does not exempt a Pod: by default no QoS class gets a memory-pressure toleration.

    Play from step 2
  3. Eviction manager ranks running Pods by three things in order: whether each is using more of the starved resource than it requested, then Pod Priority, then how far over the request it sits. QoS class does not decide that order and only estimates it, because the class comes from declared requests and limits while the ranking reads live usage. See the Pod QoS Classes card.

    Play from step 3
  4. Kubelet evicts the BestEffort Pod itself, not through the Eviction API, so no PodDisruptionBudget is consulted. Under a hard threshold the spec terminationGracePeriodSeconds is ignored and each container gets only a 2s stop window before SIGKILL, not the 30s default. The Pod is set to phase Failed, reason Evicted, with a DisruptionTarget condition, and reported to the API.

    Play from step 4
  5. Memory frees up and memory.available climbs back above the threshold. After --eviction-pressure-transition-period (default 5m) of staying clear, Kubelet flips MemoryPressure back to False. Scheduling resumes for new Pods.

    Play from step 5

Sources