Configure Pi Cluster

Posted by on December 18, 2022 · 3 mins read

Preparing the Raspberry Pis

Installing OS Raspberry Pi OS

  • Download the the Raspberry Pi OS Tool video tutorial
  • https://www.raspberrypi.com/software/
  • Choose to install x64 version of Raspberry Pi OS

Image

  • Select ‘Enable SSH’

Image

  • Setup the sudo username and password.

Image

  • Configure Hostname of Raspberry Pi

Image

  • Configure Wifi (if not using ethernet).

Image

  • Burn the Image to the Pi. And Repeat.

K3s Installation

How to run Ansible with Linux / WSL / MacOS

Skip this section if you’ve already got ansible installed and configure. if not, then the easiest way of using ansible I’ve found is via a pip install. Depending on your OS will depend on your package manager for the next step, in my case Im using Ubuntu.

sudo apt-get update
sudo apt-get install -y python3 python3-venv python3-pip
sudo python3 -m pip install ansible

or if you do not want to install ansible globally, then you can do my preferred install which is a local environment for ansible via:

cd ~
mkdir ansible
cd ./ansible
python -m venv ./local
source ./local/bin/activate
python3 -m pip install ansible

The above will create a local directory in the folder ansible, from there it will install the chain of applications needed to run it and with the source command will attach it to the path of the current terminal session. Note, for each new terminal session you will have to reenter source ./local/bin/activate.

Installing k3s via ansible.

  • Checkout the following repository
  • Update the hosts.ini file with your master if only one node or a mater and workers` if you’re lucky enough to have access to multiple spare Pis
  • Once edited, run the following:
 ansible-playbook site.yml

Installing and configuring Kubectl

Once ansible script has ran, you will need to copy the kube config file from the master node. The easiest way todo this is via scp.

mkdir ~/.kube
scp pi@<master node ip>:/home/pi/.kube/config  ~/.kube/config

Next, we will need to install kubectl

sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo apt-get install -y apt-transport-https
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gp
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

for alternative installs have a look at kubernetes documentation : here

Once installed, you can test the kubectl on the command line with the command below:

kubectl get pods -n kube-system

Alternative Management Tools for Managing the Cluster

For those who want a more visual management experience, there’s a number of good GUI and terminal tools. Here are a list and URLs for some of my favorites:

Rancher

URL https://www.rancher.com/ Github: https://github.com/rancher/rancher

K9S

URL https://k9scli.io/ Github: https://github.com/derailed/k9s