Hard vs Soft Kubelet Memory Eviction Thresholds on cgroup v2 Nodes
0 reputation · 11 Nov 2020, 23:12 UTC
0 reputation · 11 Nov 2020, 23:12 UTC
Decide whether to configure kubelet hard memory eviction thresholds, soft thresholds with grace periods, or both for memory.available on Linux nodes running cgroup v2.
Kubelet evaluates memory.available each housekeeping interval. Hard thresholds trigger immediate eviction; soft thresholds start a per-pod grace period. Documentation indicates hard eviction takes precedence when both fire in the same cycle, but it does not specify pod selection order across QoS classes and priority classes during concurrent triggers. Since Kubernetes 1.25, cgroup v2 memory.current includes kernel memory, so memory.available can appear lower than under cgroup v1 and shift threshold behavior. Kubelet emits no separate event or metric for the start of a soft grace period versus execution of a hard eviction, and --eviction-minimum-reclaim applies across all signals rather than per signal. Confirming which threshold terminated a pod requires correlating kubelet eviction metrics with pod status fields.
37275 reputation · 12 Nov 2020, 05:20 UTC
Run both hard and soft memory.available thresholds only when the soft threshold is set above the hard threshold. Hard precedence does not make soft redundant: soft starts a per-pod grace period before the hard floor is reached, while hard triggers immediate eviction as a last resort. If soft is at or below hard, hard can evict in the same cycle and soft adds little operational value.
memory.available each housekeeping interval.memory.current includes kernel memory, so memory.available can read lower than under cgroup v1 for identical workloads.reason: Evicted does not reliably distinguish hard from soft eviction.--eviction-minimum-reclaim applies across all signals, not per signal.stat -fc %T /sys/fs/cgroup should return cgroup2fs, and check kubelet --version. The kernel-memory caveat mainly matters on kubelet 1.25+.memory.available<500Mi, soft memory.available<750Mi with --eviction-soft-grace-period such as 2m.memory.current.kubectl get pod <pod> -o yaml container terminated.finishedAt timestamps against kubelet logs in the same window. Immediate breach-to-kill in one housekeeping cycle indicates hard eviction; an earlier soft-threshold or grace-period log followed by termination after the grace period indicates soft eviction.reason: Evicted alone is not sufficient.kubelet --version and stat -fc %T /sys/fs/cgroup on a representative node.memory.available under representative load, then adjust thresholds and observe eviction-pressure transitions.--eviction-soft-grace-period elapses.Are your nodes running cgroup v2 with kubelet 1.25 or later? If not, the kernel-memory accounting difference may not apply, and cgroup v1 threshold values may transfer more directly.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.