Disabling Swap Space
Disabling of swap space on all master and worker nodes is necessary to evenly distribute resources and not allocate swap space.
This procedure does not apply to database nodes, because the database requires swap space. In the case where the database and Kubernetes master and worker nodes are co-located, such as an all-in-one single node deployment, you must enables swap because it is a hard requirement for the database installation. In such a single-node scenario, Kubernetes will operate properly with swap enabled because pod allocation is only to a single node, so swap does not affect the allocation logic.
To disable swap space:
- Log on to the node.
- Run the following command to disable the swap process.
- Open the
/etc/fstab
file in a supported editor. - Comment out the lines that display
swap
as the disk type, then save the file. For example:
# swapoff -a
#/dev/mapper/centos_shcentos72x64-swap swap