Sobes.tech
Middle

Where else, besides Kubernetes nodes, can you disable swap?

sobes.tech AI

Answer from AI

On virtual machines used as the Kubernetes Control Plane. On hosts running Docker Swarm agents or managers. On servers where container registries (e.g., Docker Registry) are deployed. On nodes performing load balancing roles (e.g., HAProxy, Nginx). On machines running CI/CD agents or servers (e.g., Jenkins, GitLab Runner). On database servers used by applications:

  • PostgreSQL
  • MySQL
  • MongoDB
  • Redis On machines with monitoring and logging systems installed:
  • Prometheus
  • Grafana
  • Elasticsearch
  • Logstash
  • Kibana

In general, it is advisable to disable swap on all servers performing critical functions or processing large volumes of data to avoid unpredictable performance degradation.

How to check the swap status:

# Check current swap usage
free -h

# Check active swap partitions or files
swapon --show

How to temporarily disable swap:

# Disable all swap partitions and files
sudo swapoff -a

How to permanently disable swap (by editing /etc/fstab):

# Open the /etc/fstab file for editing
sudo nano /etc/fstab

Find the line with the swap type and comment it out by adding # at the beginning of the line.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added or removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /               ext4    errors=remount-ro 0       1
#/swapfile                                 none            swap    sw             0       0

After saving changes in /etc/fstab, either reboot the server or run sudo swapoff -a to disable swap immediately. Ensure that the system does not require swap for normal operation before disabling.