Automated and repeatable method of deploying a headless Kubernetes stack onto a cluster of Raspberry Pis. Completely hands off experience from power on.
Detailed blog and guide posted onto my medium account:
The following tools and pre-requisites must be available on the machine being used to build the SD cards:
- Linux - Because of filesystem requirements
bash
- 4.0+make
- 4.1+- kubectl - 1.20.4
- 4 Raspberry Pis (3 Masters and 1 Worker)
This stack is an opinionated way to deploy a home cluster with a HA design
using haproxy
and keepalived
for cluster management.
See below for a list of the versions and applications used:
- Raspbian - raspbian_lite-2020-02-14
- Kubernetes - 1.20.4
- Docker - 19.03.9
- HA Proxy - 1.8.19
- Keepalived - 2.0.10
- Flannel - As per instructions on kubeadm installation page
A short explanation of each environment variable that can be overridden.
MNT_DEVICE
- Device name of SD slot on your local machine. (default:/dev/mmcblk0
)
RPI_NETWORK_TYPE
- Network option of choice. Eithereth0
orwlan0
. (default:wlan0
)RPI_HOSTNAME
- Hostname for specific Raspberry Pi. (default:rpi-kube-master-01
)RPI_IP
- Static IP to set. (default:192.168.1.101
)RPI_GATEWAY
- Generally your router ip. (default:192.168.1.1
)RPI_DNS
- Usually the same as your router unless you run a separate DNS (default:RPI_GATEWAY
)RPI_TIMEZONE
- Local timezone. (default:Australia/Melbourne
)
KUBE_NODE_TYPE
- Type of Kubernetes node. Eithermaster
orworker
. (default:master
)KUBE_MASTER_VIP
- Floating virtual IP (VIP) to use inkeepalived
. (default:192.168.1.100
)KUBE_MASTER_IP_01
- IP of 1st master node to use inhaproxy
. (default:192.168.1.101
)KUBE_MASTER_IP_02
- IP of 2nd master node to use inhaproxy
. (default:192.168.1.102
)KUBE_MASTER_IP_03
- IP of 3rd master node to use inhaproxy
. (default:192.168.1.103
)
WIFI_SSID
- Local SSID to connect Wifi to. (default:n/a
)WIFI_PASSWORD
- Password of above SSID to connect to Wifi using wpa_supplicant. (default:n/a
)
Be mindful of an SSH key that gets generated with this build that is stored in
the output/ssh/
directory. This is not committed to git and should be treated
safe like a normal private key. If you lose this key you will no longer be able
to manage your stack. This is crucial for inter-cluster communication and
remoting for management.
Once appropriate above environment variables have been exported to suit your specific local environment, the below command will build an SD card with all automation scripts:
make build
The help target is set as the default target, so display the above brief descriptions. Use the below command as is to print to the terminal:
make