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:

  1. Log on to the node.
  2. Run the following command to disable the swap process.
  3. # swapoff -a
  4. Open the /etc/fstab file in a supported editor.
  5. Comment out the lines that display swap as the disk type, then save the file. For example:
  6. #/dev/mapper/centos_shcentos72x64-swap swap