Why Swap on Kubernetes Isn't the Same as Swap on Linux-and What You Should Do Instead
Briefly

When memory runs out in traditional Linux servers, enabling swap helps manage memory constraints effectively. However, in Kubernetes, swap doesn't provide the same benefits due to its design around predictable scheduling, especially in multi-tenant situations. Even if swap is enabled on Kubernetes nodes, processes can still suffer OOMKills or evictions because Kubernetes relies on cgroup memory limits and does not incorporate swap availability into its memory management decisions. Therefore, simply enabling swap is not enough to mitigate memory issues in Kubernetes clusters, necessitating alternative strategies for stability and cost management.
When using standard Linux, enabling swap provides a safety layer against memory exhaustion. However, Kubernetes doesn't leverage swap effectively, making it less reliable for handling memory pressure.
Kubernetes was built to handle predictable behavior in multi-tenant settings, leading to swap being disabled by default, which results in memory issues even when configured.
Read at Medium
[
|
]