I need to add swap memory in kubernates pod. so that if any pods exceeds the available RAM then it can use the swap memory from hard disk. is that possible in kubernates?
The official Kubernetes prerequisites says that:
Swap disabled. You MUST disable swap in order for the kubelet to work properly.
You are supposed to use cpu/memory limits for deployments. Kubelet is not designed to handle swap situations. If memory swapping is allowed to occur on a host system, it can lead to performance and stability issues within Kubernetes.
However there is a way to disable swap while installing kubeadm
:
/etc/systemd/system/kubelet.service.d/20-allow-swap.conf
with the following content:[Service] Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"
sudo systemctl daemon-reload
kubeadm
with flag --ignore-preflight-errors=Swap
:kubeadm init --ignore-preflight-errors=Swap
Bear in mind however that it is not a recommended way.