September 09, 2020
Install Kubernetes on Raspberry Pi OS
We’re going to use k3s, a lightweight Kubernetes distribution, to get the most of our hardware. This tutorial uses a Raspberry Pi 4 and the latest version of Raspberry Pi OS 32-bit (formerly known as Raspbian).
Flash the OS image on your SD Card and, if necessary, add Wi-Fi credentials so you can access it.
Enable cgroups support and disable IPv6 by appending the following on /boot/cmdline.txt
(remember that /boot
refers to the boot partition on your SD Card).
cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory ipv6.disable=1
Personally, I also recommend disabling swap.
dphys-swapfile swapoff && systemctl disable dphys-swapfile.service
If your workloads won’t require GPU, you may want to change the Memory Split to 16 using raspi-config
. You’ll have a little extra RAM this way.
Ensure that your OS is using legacy iptables.
iptables -F
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
Install and test Docker.
curl -fsSL https://get.docker.com | sh -
# Test if everything is running
docker run hello-world
# Optional: allow the "pi" user to run Docker as well
usermod -aG docker Pi
Install and test k3s.
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable=traefik --docker" sh -
# After a minute, you should be able to test it
kubectl get nodes
The kubeconfig yaml will be available at /etc/rancher/k3s/k3s.yaml
.