🐧 Kubernetes - Install Almalinux 🐧#
592 words | 8 min read
In the previous post, we looked at our objective of creating a bare metal Kubernetes cluster, and the high-level steps to achieve it.
Now, let us look at the steps to install Linux on each node of our cluster.
Almalinux can be installed on the mini PCs by following the Almalinux blog.
During the installation process, be sure to manually partition the disk, and add an EXT4 partition for Longhorn.
Of course, it’s better if you have a separate disk that for Longhorn. But I only have 1 256GB disk, and I partitioned it with a 135 GB partition that I will use later for Longhorn.
I used the Raspberry Pi imager and an SD Card reader to install the Almalinux 9 image on the SD Card.
We do not need any graphical environment for our purposes. So, do not enable Gnome (or KDE or anything else).
Assign unique hostnames for each node (e.g. master, worker01, worker02 etc.).
In my case, I used the following host names:
Important
If you wish to use the master node (Raspberry Pi) as one of the Longhorn storage nodes, you need to perform a few extra steps because the RPi imager does not allow you to define any additional partitions during the installation process.
Create a longhorn partition on the RPi4 SD Card#
You only need to perform these steps if you wish to use the Raspberry Pi 4 (master node) as a Longhorn storage node.
Generally, it is recommended to not use the control plane (aka master node) for storage or to run other loads. However, this is all the hardware I have, and I do not intend to run anything important on this cluster (yet).
After you burn the RPi image onto the SD Card, use it to boot the RPi4. Let the file system be expanded.
Shutdown the RPi4 and remove the SD Card.
Insert the SD Crd into another PC that runs Linux (e.g. one of the mini PCs where you just installed Almalinux).
Verify the device name assigned to the SD Card (e.g. /dev/sdc).
Run the following commands to create an additional partition matching the size of the longhorn partition that you created on the other computers.
e2fsck -f /dev/sdc2
resize2fs /dev/sdc2 100G # Adjust this suitably based on your partitioning
fdisk /dev/sdc
Then, in the fdisk prompt, perform the following steps
Delete partition 2
Create new primary partition of 100G size -> Same size as in the resize2fs command
Create more partitions as needed -> Otherwise, the pi will expand the filesystem again to fill the SD card
Write the partition table to disk and exit
Insert the SD Card into the Raspberry Pi and Boot
Disable Swap on all nodes#
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
Mount the longhorn partition#
Identify the partition number#
fdisk -l
The output will show something similar to
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 593919 585728 286M c W95 FAT32 (LBA)
/dev/mmcblk0p2 593920 210309119 209715200 100G 83 Linux
/dev/mmcblk0p3 210309120 499744767 289435648 138G 83 Linux
in this example, /dev/mmcblk0p3 is the partition earmarked for Longhorn.
Update fstab to mount the partition at boot#
We want to mount the partition at /var/lib/longhorn. So, let us update fstab to make that happen.
echo "UUID=`ls -l /dev/disk/by-uuid/ | grep "mmcblk0p3" | awk -F "->" ' { print $1 } ' | awk ' { print $NF } '` /var/lib/longhorn ext4 defaults 0 0" >> /etc/fstab
Set SELinux to permissive mode on all nodes#
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
Disable the firewall on all nodes#
systemctl stop firewalld
systemctl disable firewalld
Caution
If you’re planning to expose any of the services outside your network, keep the firewall enabled, and open specific ports alone.
For my purposes, it was less hassle to simply disable the firewall.
Add kernel parameters#
echo "net.bridge.bridge-nf-call-iptables = 1" > /etc/sysctl.d/k8s.conf
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.d/k8s.conf
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.d/k8s.conf
If everything worked, you should have 3 computers (nodes) running Almalinux, and have a separate partition on each that can be used later for Longhorn, with
Swap disabled
SELinux in permissive mode
Firewall disabled.
Now, update all packages on each node.
dnf update
Reboot them after the packages are updated.
At this point, you should be ready to configure networking and set up communication via BGP.
Comments
Comments powered by giscus, use a GitHub account to comment.