Skip to content

Latest commit

 

History

History

pi-cluster

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Raspberry Pi Cluster

A K8s cluster of Raspberry Pis is used to learn more about K8s, experiment with GitOps, and self-host my projects.

Raspberry Pi Cluster Image

Table of Contents

Tech Stack

Logo Name Description
Ansible logo Ansible Automate bare metal provisioning and configuration
ArgoCd logo ArgoCD GitOps tool built to deploy applications to Kubernetes
Docker logo Docker Containerization platform for software applications
Helm logo Helm The package manager for Kubernetes
K3s logo K3s Lightweight distribution of Kubernetes
Kong logo Kong Gateway API gateway for microservices architecture.
Kong logo Kong KIC Kubernetes ingress controller for the Kong Gateway
Kong logo Kong Konnect API connectivity and management platform
Kubernetes logo Kubernetes Container-orchestration system, the backbone of this project
Raspbian logo Raspbian Base OS for Kubernetes nodes
Renovate logo Renovate Automatically update dependencies

Usage

To create the Pi Cluster follow the below steps in order to configure the Raspberry Pis, your development PC, and then the cluster.

Raspberry Pi Configuration

Use the Raspberry Pi Imager to install Raspberry Pi OS (64 bit, lite) on each Pi's SD card. Prior to installation, update the advanced configuration in the Imager, and set the following options:

  • Set hostname: node1.local (set to 2 for node 2, 3 for node 3, etc.)
  • Enable Remote SSH: 'Allow public-key', and paste in your public SSH key(s)

After all the Pis have had their OS installed:

  • Turn on each pi
  • Connect it to the same network as your Development PC

Development PC Configuration

  • Create a Kong Konnect Account at https://cloud.konghq.com/
  • Install Ansible
  • Clone this repo
  • Update the hosts.ini file to set the correct hostnames for the contral_plane and nodes.
  • Open a terminal and run cd ./ansible && ansible all -m ping to verify that ansible can ssh into each node

Cluster Configuration

After all prerequisites have been completed, use your Development PC to run the below command, which will install K3s, ArgoCd, Kong Ingress Controller, and the Kong Gateway.

ansible-playbook ./ansible/main.yml

Note: when prompted, make sure to add the required Konnect certificates as a secret in the cluster.

Management & Maintenance

Cluster Management

After the cluster has been provisioned, you can...

  • Verify the cluster is reachable curl -i node1.local:80.
  • Use kubectl to manage the cluster (e.g. view all pods with kubectl get pods --all-namespaces).

Note: The K3s' kubeconfig file is located at /etc/rancher/k3s/k3s.yaml. If you'd like to manage the cluster from other hosts (or using a tool like Lens), copy the contents of that file, replacing localhost with the IP address or hostname of the control plane node, and paste the contents into a file ~/.kube/config.

Cluster Maintenance

The following ansible tasks have been created to assist with day to day maintenance:

  • Shutdown the cluster: ansible-playbook ./ansible/tasks/util/shutdown.yml
  • Upgrade the cluster: ansible-playbook ./ansible/tasks/util/upgrade.yml
  • Uninstall k3s from the cluster: ansible-playbook ./ansible/tasks/util/uninstall.yml

Miscellaneous

Parts List

  • 1 x Raspberry Pi Model 4b 4gb (master node)
  • 2 x Raspberry Pi Model 4b 2gb (worker node)
  • 3 x Samsung EV0+ 32GB microSD card
  • 3 x Raspberry Pi Poe HAT
  • 3 x Raspberry Pi Stackable Case
  • 3 x 15cm Cat6 ethernet cables
  • 55W 4xPoE+ 5-port Gigabit Network Switch

Post Provisioning Diagram

TBD