I'm creating this guide as I cannot find an updated guide anywhere that contains these specific series of steps needed to properly install k3s on a Raspberry Pi. In this case, I'm choosing to go with Ubuntu Server 23.04.
-
Flash your microSD card with the Rasperry Pi Imager. Select Ubuntu Server 23.04 (64-bit) under OS.
The imager also includes a cloud init config via the UI - which can help you set up the hostname and pre-authorize SSH keys. Note: If you confiure wireless LAN here, you will need to manually set up
eth0
withnetplan
. -
Boot up your Raspberry Pi and ssh into it.
-
Enable these OS container features for Docker and Kubernetes to work properly. Reference
sudo sed -i '$ s/$/ cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1/' /boot/firmware/cmdline.txt
-
Let's also disable UFW while we're here per SUSE's recommendations.
sudo ufw disable
-
Install these extra modules needed for the Raspberry Pi.
sudo apt upgrade sudo apt install linux-modules-extra-raspi
-
Ubuntu will complain that the kernel is not up to date, so let's reboot to use the updated version and apply our OS container flags with
sudo reboot
. -
Next, install k3s per their quick start guide. I'm choosing to use NGINX instead of traefik here, which we will configure later.
Note: The flag
--no-deploy
is deprecated, so we need to use--disable
instead.curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --disable traefik" sh
-
Get the kube config from
cat /etc/rancher/k3s/k3s.yaml
and merge the certificate and secrets into your local.kube/config
file, so you can connect to the k3s cluster from your device. -
Now that you can call the API from your device, switch to that context and run this command to make sure you have access:
kubectl config use-context $CONTEXT_NAME kubectl get all --all-namespaces
-
Deploy the NGINX ingress via helm.
helm upgrade --install ingress-nginx ingress-nginx \ --repo https://kubernetes.github.io/ingress-nginx \ --namespace ingress-nginx --create-namespace
-
Optional: Deploy the Kubernetes Dashboard by applying this config:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
You can then follow the steps here to access the dashbaord.
-
That's it! You can also create a demo deployment to make sure it's working.
kubectl create deployment demo --image=nginx --port=80 kubectl create ingress demo --class=nginx --rule="$HOSTNAME/*=demo:80"