Build a Kubernetes (K3s) cluster with Raspberry Pis, using Anisble to bootstrap the machines, and utilizing ArgoCD for managing cluster state.
Do not expect the git history for this repository to be clean and tidy.
- This was done using a cluster of 4 x RPi 4 4GB
- All Pi's are connected via a local ethernet switch on a 10.0.0.0/24 LAN
- The master node connects to the outside world on WiFi, and provides NAT for the rest of the cluster.
.
│ # Ansible playbooks to bootstrap the cluster
├── ./ansible
│ # Docker builds for ARM devices
├── ./docker
│ # ArgoCD will deploy from this directory
├── ./gitops
│ # Scripts and config for setting up the Raspberry Pis
└── ./scripts
│ # Cloud-init config for Raspberry Pi Imager
└─ ./cloud-init| IP | Function | MAC Address |
|---|---|---|
| 192.168.115.1 | Router | |
| 192.168.115.193 | Master wifi interface | |
| 10.0.0.0/24 | k3s cluster CIDR | |
| 10.0.0.1 | k3s master (master) | dc:a6:32:67:76:f1 |
| 10.0.0.2 | k3s worker (node-1) | dc:a6:32:67:77:3e |
| 10.0.0.3 | k3s worker (node-2) | dc:a6:32:67:76:b8 |
| 10.0.0.4 | k3s worker (node-3) | dc:a6:32:67:77:06 |
- 4 x Raspberry Pi 4 Model B 4GB
- 4 x Raspberry Pi PoE Hat
- 4 x SanDisk Ultra microSDHC Memory Card
- 4 x 15cm Flat Cat 6 cables
- 4 x Low profile heatsinks
- 4 x WD Green 240GB 2.5" SSD
- 4 x SSD to USB 3.0 Cable
- Uctronics Cluster Enclosure V3.0
- MicroSD Extender Set for Uctronics Cluster Cases
- NETGEAR 5-Port Gigabit Ethernet PoE Switch
- Ensure that Raspberry Pi Imager is installed along with
kubectlandkubecm - Run
make flashto flash the SSD drive for each RPI using RPI Imager. It will flash withUbuntu Server 24.04.3 LTS (64-bit)and copy thenetwork-config&user-datarelevant to the node to the SSD. - Edit
~/.ssh/configon the local machine to include the following (see REBELinBLUE/dotfiles)
Host master
Hostname cluster.lan # Or the IP address
User ubuntu
Host node-1
Hostname 10.0.0.2
ForwardAgent yes
User ubuntu
ProxyJump master
Host node-2
Hostname 10.0.0.3
ForwardAgent yes
User ubuntu
ProxyJump master
Host node-3
Hostname 10.0.0.4
ForwardAgent yes
User ubuntu
ProxyJump master
- Plug in the master RPI and let it boot
- Run
make masterto set up the master - Plug in the 3 remaining nodes and let them boot
- Run
make workersto set up the worker nodes - Run
make clusterto set up K3s, this will copy and merge the kubeconfig locally and set the context topi. - Once the cluster has been started, ArgoCD will been installed and this with then install the content of the cluster.
- Run
make argoto get the ArgoCD initial admin password, then access the ArgoCD UI athttp://localhost:8090with usernameadminand the retrieved password. - Run
make secretsto update sealed secrets so the remaining applications can start. The secrets are sourced from a 1password environment.
