Installing k3s on Ubuntu on Raspberry Pi
Learn how to install k3s on Ubuntu running on Raspberry Pi, including setup for control plane and agents. Follow this guide for a smooth installation process.
Installing k3s on Ubuntu on Raspberry Pi
After reinstalling all of my nodes with Ubuntu, it’s time to install k3s. Here’s a step-by-step guide to get it running smoothly.
Installing Needed Modules
Per k3s#4234, k3s requires some extra modules that aren’t installed by default on Ubuntu. Install them with:
sudo apt install linux-modules-extra-raspi
Installing k3s Control Plane
Follow the instructions from the Rancher k3s Quick-Start Guide.
On the first node, run:
curl -sfL https://get.k3s.io | sh -
Then wait, occasionally running:
sudo k3s kubectl get nodes
to check on progress.
Installing k3s Agents
Once the control plane is up, grab the server token:
sudo cat /var/lib/rancher/k3s/server/node-token
On the other nodes, run:
curl -sfL https://get.k3s.io | K3S_URL=https://rpi401:6443 K3S_TOKEN=<node-token> sh -
Setting Up KUBECONFIG
Back on the primary node:
mkdir ~/.k3s
sudo cp /etc/rancher/k3s/k3s.yaml ~/.k3s/k3s.yaml
sudo chown $USER.$USER ~/.k3s/k3s.yaml
export KUBECONFIG=$HOME/.k3s/k3s.yaml # add this to ~/.bashrc
Enabling Shell Auto-Completion
Follow the instructions from the Kubernetes documentation:
echo 'source <(kubectl completion bash)' >>~/.bashrc
Checking if it Works
Finally, verify the setup by running:
kubectl get nodes
Example output:
NAME STATUS ROLES AGE VERSION
rpi401 Ready control-plane,master 80m v1.21.7+k3s1
rpi405 Ready <none> 28s v1.21.7+k3s1
rpi404 Ready <none> 18s v1.21.7+k3s1
rpi403 Ready <none> 18s v1.21.7+k3s1
rpi402 Ready <none> 32s v1.21.7+k3s1
By following these steps, you can successfully install k3s on Ubuntu running on Raspberry Pi, setting up both the control plane and agents effectively.