Kubernetes on Raspberry Pi 5 — Part 4 Install K3S on agent nodes

Ionut Banu
2 min readJul 12, 2024

--

I have been using a Raspberry Pi 4 as a host for a Kubernetes for about two years. Recently I purchased the new Raspberry Pi 5. I plan to also setup Kubernetes on it so I can have a cluster with two nodes.

K3s on Raspberry Pi 5

Part 1 Install Raspberry Pi OS Lite 64-bit

Part 2 Mount external storage

Part 3 Install K3S on master node

Part 4 Install K3S on agent nodes

Part 5 Install network load balancer (MetalLB)

So far I have went through the process of setting up K3S on a Raspberry Pi 5 board. This board will be the master node. Now I will add a second node or agent node. The steps are the same for adding more agent nodes. I will add my old Raspberry Pi 4 board as an agent node.

Retrieve node token

The first thing we need to do is to retrieve the access-token from the master node. You can do this by executing the following command on the master node:

sudo cat /var/lib/rancher/k3s/server/node-token

Setup agent node

Now move to the worker board and make sure you apply the instructions from step 1 (Update kernel configuration file) in this article Part 3 Install K3S on master node.

Use the token obtained above to replace the <ACCESS_TOKEN> placeholder below. Also use the IP of the master node to replace the <MASTER_NODE_IP> placeholder.

export K3S_NODE_NAME="piworker1"
export K3S_KUBECONFIG_MODE="600"
export K3S_URL="https://<MASTER_NODE_IP>:6443"
export K3S_TOKEN="<ACCESS_TOKEN>"
export INSTALL_K3S_EXEC="agent --server $K3S_URL --token $K3S_TOKEN"

After setting these variables you will have to run the following command:

curl -sfL https://get.k3s.io | sh -

To check if the k3s service is running run this command:

sudo systemctl status k3s-agent

The output will start with something similar to the text block below:

● k3s-agent.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s-agent.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-07-12 15:29:46 EEST; 6h ago

To check if the agent node has been added you can go back to the master node or a machine that has remote access to execute kubectl commands and execute this command:

kubectl get node

The output should look similar to this:

NAME        STATUS   ROLES                       AGE   VERSION
pimaster Ready control-plane,etcd,master 30d v1.29.5+k3s1
piworker1 Ready <none> 28d v1.29.5+k3s1

Done!

--

--

Ionut Banu
Ionut Banu

No responses yet