Node Configuration
Overview
This guide will go over the basic OS/hardware config on a Raspberry Pi, along with some additional apps/tunings to help things play nicely further in the series.
Step 1 - Install Raspberry Pi OS
The following YouTube video, provided by the Raspberry Pi Foundation is a great overview on how to use their excellent imaging software to write a Raspberry Pi OS image to a MicroSD Card.
I would recommend the usage of the 64bit lite release.
Step 2 - Connect via SSH to the Raspberry Pi (RPi)
Once installed, connect your RPi to your home network, wait for it to boot, and then SSH in to begin configuring.
A good guide for this step is again available from the RPi website - here
Step 3 - Base Configuration
Adjust RAM Allocation for GPU to 16Mb
The display output on the RPi will not be used, so lets claim some extra RAM back for the system to use.
sudo raspi-config
Navigate -
- Performance Options-> GPU Memory
- Change to '16'
- Back
You can do this manually by editing the /boot/config.txt file
and adding/editing gpu_mem=16
to the file.
Add support for cgroups
Raspberry Pi OS does not have cgroups enabled.
K3s needs cgroups to be able to start the systemd service.
cgroupscan
be enabled by appending cgroup_memory=1 cgroup_enable=memory
to the end of the line in /boot/cmdline.txt
.
You can do this with nano -
Then add to the bottom -
sudo nano /boot/cmdline.txt
Save and exit -
ctrl+o
ctrl+x
Rename System
This is basically to allow us to easily identify the device on the network & in the cluster, through its hostname.
In same raspi-config as previous step:
- System Options
- Hostname
- Type in new hostname
- Finish
I would recommend a logical naming convention for cluster nodes, that go up sequentially.
Such as -
- RPi-K3s-Node01
- RPi-K3s-Node02
- RPi-K3s-Node03
You can pre-set the system names in the advanced options menu of Raspberry Pi imager.
Step 4 - Install & Configure Log2RAM
Log2RAM is a storage solution that allocates a small % of your physical RAM as RAM Cache, and uses it to store log data from the system, flushing to disk on a regular schedule.
This is important to have in place where the OS partition is on a storage device that has to do wear leveling, so SSDs & SDs.
On a RPi, its doubly important as MicroSD's do not have the endurance to have sustained log writing to the disk for long periods without eventually killing the MicroSD.
This site her has a good breakdown of what it does in practice.
Install Log2RAM
echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bullseye main" | sudo tee /etc/apt/sources.list.d/azlux.list
sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
sudo apt update && sudo apt install log2ram
Configure Log2RAM
Increase RAM allocation
sudo nano /etc/log2ram.conf
Change SIZE
variable (line 8) to 128M
.
Save and exit -
ctrl+o
ctrl+x
Increase frequency of log flushing
sudo systemctl edit log2ram-daily.timer
Add the below block below line 2, but above the warning that says "Lines below this comment will be discarded".
Due to the amount of logs that K3s can generate, this will ensure that the log drive does not fill up, by increasing the frequency of how often it flushes the data from RAM to disk.
[Timer]
OnCalendar=*-*-* */12:00:00
Persistent=true
Install additional apps
Run the following to add some additional apps to the base OS that will be needed later.
sudo apt install open-iscsi -y
Step 5 - Configure 'Swappiness'
Edit config file
sudo nano /etc/sysctl.conf
Add to the bottom of the file -
vm.swappiness=0
Save and exit -
ctrl+o
ctrl+x
You can also do this with a one-liner, sudo echo "vm.swappiness=0" >> /etc/sysctl.conf
Step 6 - Edit the Host file
Next we edit the system host file so it has hard coded local DNS entries for key services, and each other.
Then add to the bottom -
sudo nano /etc/hosts
Then add to the bottom -
192.168.0.231 rpi-k8s-01
192.168.0.232 rpi-k8s-02
192.168.0.233 rpi-k8s-03
192.168.0.234 rpi-k8s-04
192.168.0.235 rpi-k8s-05
192.168.0.236 rpi-k8s-06
192.168.0.251 logserver
192.168.0.250 storageserver
Edit the IPs and names accordingly.
Save and exit -
ctrl+o
ctrl+x
You can also do this with a one-liner too -
sudo echo "192.168.0.1 RPi-K8s-01" >> /etc/hosts
sudo echo "192.168.0.2 RPi-K8s-02" >> /etc/hosts
sudo echo "192.168.0.3 RPi-K8s-03" >> /etc/hosts
sudo echo "192.168.0.10 logserver" >> /etc/hosts
sudo echo "192.168.0.11 storageserver" >> /etc/hosts
Step 8 - Set static IP
Taking the IP addresses you set in Step 6, we now need to give our nodes static IPs.
We can do this either on the node itself, or if your network has DHCP capabilities, use a DHCP reservation instead.
If you do it on the node itself, the guide here is very useful, but be sure to use the same IPs you chose in step 6.
Step 9 - Reboot
Now you can reboot -
sudo reboot
Next Step
Next, go to the next step, installing K3s.
Or,
Go back to the index page.