A K8s cluster of Raspberry Pis is used to learn more about K8s, experiment with GitOps, and self-host my projects.
Logo | Name | Description |
---|---|---|
Ansible | Automate bare metal provisioning and configuration | |
ArgoCD | GitOps tool built to deploy applications to Kubernetes | |
Docker | Containerization platform for software applications | |
Helm | The package manager for Kubernetes | |
K3s | Lightweight distribution of Kubernetes | |
Kong Gateway | API gateway for microservices architecture. | |
Kong KIC | Kubernetes ingress controller for the Kong Gateway | |
Kong Konnect | API connectivity and management platform | |
Kubernetes | Container-orchestration system, the backbone of this project | |
Raspbian | Base OS for Kubernetes nodes | |
Renovate | Automatically update dependencies |
To create the Pi Cluster follow the below steps in order to configure the Raspberry Pis, your development PC, and then the cluster.
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 to2
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
- 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
andnodes
. - Open a terminal and run
cd ./ansible && ansible all -m ping
to verify that ansible can ssh into each node
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.
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 withkubectl 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
.
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
- 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
TBD