Skip to content

k3s

Requirements

Disable swap

When installing Kubernetes on Linux, it’s recommended to disable swap because of how Kubernetes manages resources.

  • Memory Management: Kubernetes efficiently manages and allocates resources, including memory. Allowing an operating system to swap can interrupt Kubernetes’ memory management process.
  • Performance Issues: Swapping can lead to performance degradation. When Kubernetes needs to access something that has been swapped to disk, it must wait for it to be loaded back into memory, causing delays.
  • Predictability: Disabling swap helps ensure predictable performance, as it removes the chance of the system swapping out Kubernetes’ processes.
  • Kubernetes Design: Kubernetes is designed to work with no swapping activity. It assumes that applications are memory-resident, which means it expects them to stay in memory all the time.
1
nano /etc/dphys-swapfile
1
CONF_SWAPSIZE=0
1
reboot

Cgroup configuration

If a FATA[0000] failed to find memory cgroup (v2) error surfaces during the installation of k3s, it is likely because the Pi OS lacks the required cgroup configuration. Below are the steps needed to resolve this issue:

1
nano /boot/firmware/cmdline.txt
1
cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
1
reboot

Install K3S

https://k3s.io/

1
curl -sfL https://get.k3s.io | sh -
1
/usr/local/bin/k3s-uninstall.sh

Check for Ready node, takes ~30 seconds

1
sudo k3s kubectl get node

Kubeconfig is written to /etc/rancher/k3s/k3s.yaml

1
cat /etc/rancher/k3s/k3s.yaml