HomeLab – Deployment of an HA Kubernetes cluster (Part 4 – K3s nodes installation)

Before we get started let’s create a table

VariableRoleExample or explanationExample IP
NODE_TOKENToken taken from the server nodes for agent installations

Although optional it would be a good idea to create on your local DNS the entries for all nodes and especially for the load balancer ip.

SSH on your first node, get sudo privileges and run this command replacing the variables with your settings.

IMPORTANT NOTE: At the point pf writing Rancher 2.7.0 is supported on Kubernetes version 1.24 and bellow so before the deployment make sure you are installing a compatible release.

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.24.10-rc1+k3s1 sh -s - server \
--token=SECRET_TOKEN \
--tls-san SRV1_DNS_NAME --tls-san LOAD_BALANCER_IP \

After it is finished check the installation

kubectl get nodes

Now add the other servers by connecting to them and

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.24.10-rc1+k3s1 sh -s - server \
--token=SECRET_TOKEN \
--tls-san SRV2_DNS_NAME --tls-san LOAD_BALANCER_IP \
--server https://SRV1_IP_ADDRESS:6443

After all three servers are finished on one of them

kubectl get nodes

Now let’s add the worker nodes.

First let’s get the token from one of the Master nodes

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

SSH to them, get sudo privileges and

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.24.10-rc1+k3s1 sh -s - agent \
--server https://LOAD_BALANCER_IP:6443 \
--token NODE_TOKEN

replacing the NODE_TOKEN with the result of the cat command on the previous step

NOTE: If you are using Ubuntu 22.04 on a Raspberry Pi like I am, make sure to install the linux extra modules for the pi first.

sudo apt install linux-modules-extra-raspi

Now that all five nodes are configured.

kubectl get nodes

Congratulations you have an HA Kubernetes cluster!

For the Raspberry PI nodes you might want to add a label to them in order to differentiate them from the usual x86 or x64 architecture. Since they are PI4Bs in my case they have an ARM64 processor.

 kubectl label nodes k3s-cl01-04 k3s-cl01-05 cputype=arm64

This is totally optional and unless you are creating a custom application yourself you will not need it. You can use this label, which is free text, to deploy or not to deploy containers to these nodes. So if you type in

kubectl describe node k3s-cl01-04

You can see the label added

NOTE: To uninstall k3s on the node:


And on the cluster

kubectl delete node NODE_NAME

Leave a Reply

Your email address will not be published. Required fields are marked *