# Swap Off - why is it necessary?

**URL:** <https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879>\
**Category:** General Discussions\
**Created:** [June 21, 2019, 4:13pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879 "2019-06-21T16:13:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinwlai2](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@justinwlai2](https://discuss.kubernetes.io/u/justinwlai2)\
**Post date:** [June 21, 2019, 4:13pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/1 "2019-06-21T16:13:59Z")

</div>

Just a generic question about this. I saw this command in a tutorial but I’m not sure why it’s there?

swapoff -a && sed -i ‘/ swap / s/^/#/’ /etc/fstab

---

<div class="post-metadata">

**Author:** ![thockin](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/thockin/32/2457_2.png) [@thockin](https://discuss.kubernetes.io/u/thockin)\
**Post date:** [June 21, 2019, 4:26pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/2 "2019-06-21T16:26:54Z")

</div>

If you run nodes with (traditional to-disk) swap, you lose a lot of the isolation properties that make sharing machines viable. You have no predictability around performance or latency or IO.

---

<div class="post-metadata">

**Author:** ![outcoldman](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/outcoldman/32/1495_2.png) [@outcoldman](https://discuss.kubernetes.io/u/outcoldman)\
**Post date:** [June 23, 2019, 5:25pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/3 "2019-06-23T17:25:41Z")

</div>

The discussion about this is in this issue [https://github.com/kubernetes/kubernetes/issues/53533](https://github.com/kubernetes/kubernetes/issues/53533)

---

<div class="post-metadata">

**Author:** ![Claire](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/claire/32/7630_2.png) [@Claire](https://discuss.kubernetes.io/u/Claire)\
**Post date:** [May 13, 2021, 1:03pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/4 "2021-05-13T13:03:30Z")

</div>

To complete the @thockin comment, as the doc precise as a requirement at the beginning of the [Installing kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#before-you-begin) process:

> You MUST disable swap in order for the kubelet to work properly.

I would add this command to be totally sure everything is disabled:

```auto
# First diasbale swap
sudo swapoff -a

# And then to disable swap on startup in /etc/fstab
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

```

---

<div class="post-metadata">

**Author:** ![mrbobbytables](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/mrbobbytables/32/7_2.png) [@mrbobbytables](https://discuss.kubernetes.io/u/mrbobbytables)\
**Post date:** [May 14, 2021, 12:42pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/5 "2021-05-14T12:42:22Z")

</div>

Swap support is actually in the works, but there will be some caveats with running it enabled. For details check out [KEP-2400: Node system swap support](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2400-node-swap).

---

<div class="post-metadata">

**Author:** ![AviHaim](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/avihaim/32/9223_2.png) [@AviHaim](https://discuss.kubernetes.io/u/AviHaim)\
**Post date:** [December 29, 2021, 1:51pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/6 "2021-12-29T13:51:36Z")

</div>

do I need to swap off on worker nodes as well? or just on Master node?

---

<div class="post-metadata">

**Author:** ![Burak\_Karakurum](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/burak_karakurum/32/11619_2.png) [@Burak\_Karakurum](https://discuss.kubernetes.io/u/Burak_Karakurum)\
**Post date:** [January 15, 2023, 12:22pm UTC](https://discuss.kubernetes.io/t/swap-off-why-is-it-necessary/6879/7 "2023-01-15T12:22:09Z")

</div>

you should swap off all nodes

> **[How to Install Kubernetes Cluster on Ubuntu 22.04](https://www.linuxtechi.com/install-kubernetes-on-ubuntu-22-04/)**
>
> In this guide, we will cover how to install kubernetes cluster on Ubuntu 22.04. Kubernetes is a free and open-source container orchestration tool.
