<p>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?</p>

<p>As of <em>Kubernetes 1.22</em>, swap memory is supported (as an alpha feature).</p>
<ol>
<li>Configure the node's host OS with a swap memory device (e.g., with <code>swapon</code> or <code>/etc/fstab</code>);</li>
<li>Configure kubelet on that node to:
<ul>
<li>still start despite detecting the presence of swap (disable <code>fail-on-swap</code>),</li>
<li>enable the <code>NodeSwap</code> feature gate, and</li>
<li>configure <code>MemorySwap.SwapBehavior=UnlimitedSwap</code> to let kubernetes workloads use swap memory.</li>
</ul>
</li>
</ol>
<p>Note, there is currently no support for setting swap limits individually per workload (although this is planned for the beta). Either no containers are permitted to use any swap, or all containers can use unlimited swap memory.</p>
<p>(If workloads are <em>not</em> permitted to use swap then, depending on the Linux kernel cgroups version, they could still get swapped anyway. Prior to cgroups v2, processes were not able to enforce separate limits for swap and physical memory, but only for the combined total.)</p>
<p>See the <a href="https://kubernetes.io/docs/concepts/architecture/nodes/#swap-memory" rel="nofollow noreferrer">docs</a>, and the kubernetes enhancement proposal (KEP) cited therein, for more details.</p>
