Setting up the Raspberry Pi’s
This guide is great for the setup up the Raspberry Pi’s and also include the K3S and MetalLB deployment described here.
Once the OS is installed and the Nodes are accessible using SSH we can begin the deployment process
As part of the OS installation with the Raspberry Pi Imager I already set my Hostnames as required
I also Used my DHCP server to assign fixed IP’s to each Pi
SHomeK3SM01 – 10.30.0.10 – Master Node
SHomeK3SW01 – 10.30.0.11 – Worker Node 1
SHomeK3SW01 – 10.30.0.12 – Worker Node 2
SHomeK3SW01 – 10.30.0.13 – Worker Node 3
You can use hostname and ip a to confirm this
ubuntu@SHomeK3SM01:~$ hostname SHomeK3SM01
ubuntu@SHomeK3SM01:~$ ip a show dev eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether e4:5f:01:0a:5e:1c brd ff:ff:ff:ff:ff:ff inet 10.30.0.10/24 brd 10.30.0.255 scope global dynamic eth0 valid_lft 82137sec preferred_lft 82137sec inet6 fe80::e65f:1ff:fe0a:5e1c/64 scope link valid_lft forever preferred_lft forever
Our First task is to get the OS ready to run Containers.
The below needs to be run on all Nodes. As per the Guide mentioned this can be done using Ansible but I Used mtputty to just run it on al 4 nodes at once
sudo sed -i '$ s/$/ cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1/' /boot/firmware/cmdline.txt
Fixing IP Tables can be done by creating a k3s.conf file with the config
echo "net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1" > ~/k3s.conf
now this needs to be moved to the correct path and the correct permissions and owner set
sudo mv k3s.conf /etc/sysctl.d/k3s.conf sudo chown root:root /etc/sysctl.d/k3s.conf sudo chmod 0644 /etc/sysctl.d/k3s.conf
If you also dislike IPv6 then append the below to your /etc/sysctl.d/99-sysctl.conf file
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 net.ipv6.conf.eth0.disable_ipv6 = 1
Time for a Reboot before we continue.
Time to start the K3S setup, This is done easily with a Install script and some parameters.
I will start with the single master node.
sudo curl -sfL https://get.k3s.io | K3S_TOKEN="Your Super Awesome Password" sh -s - --cluster-init --disable servicelb
The –cluster-init is to initialize the first node. We also use –disable servicelb as we will be using MetalLB for load balancing.
Give it about a minute to settle. you can check that the node is up using sudo kubectl get nodes
Next up the Worker Nodes. The K3S_URL should be set to the IP of the Master Node you deployed earlier, the FQDN can also be used.
sudo curl -sfL https://get.k3s.io | K3S_URL="https://10.30.0.10:6443" K3S_TOKEN="Your Super Awesome Password" sh -
Now I like to do a watch and just check that all the nodes are up
To make it look a bit prettier I like to label my Worker Nodes
In the next Post we will deploy MetalLB and the Monitoring.