This Ansible playbook turns your fleet of Raspberry Pi into Kubernetes cattle with k3s, the streamlined version of Kubernetes by @rancher that runs silky smooth on the ARM processor powering your Pi.
- Burn Raspian Stretch Lite on an SD card with EtcherBalena, or something alike
- Create an empty
ssh
file in the root of the SD card (volume is calledboot
)
Optional but advisable: use SSH key auth and disable password login.
The default ssh credentials for a Raspberry Pi are username pi
and password raspberry
.
- Copy your pubkey to the Pi with
ssh-copy-id [email protected]
- In
/etc/ssh/sshd_config
on the Pi, setPasswordAuthentication
tono
- Copy
ansible/hosts.template
toansible/hosts
for your configuration - Choose one of the Raspberries to lead / orchestrate your cluster; we'll call this the server
- In
ansible/hosts
, fill out the ip or hostname for the leading Raspberry under[k3s-server]
- Fill out the ip's or hostnames for the rest of your cattle under
[k3s-agents]
I personally prefer using the Pi's hardware mac address to assign a hostname and ip address within the LAN by DHCP, but you could also set a static ip address on the Pi.
When you're all set up and configured, run the Ansible playbook:
$ make
This will:
- Install the k3s binary on the 'server' Pi (the leading node)
- Install a
k3s-server
service on the server and start it - Fetch the node token from the server
- Install and start a
k3s-agent
service on the agents, joining the cluster - Enable autostart on boot for k3s on all nodes
Log into your server node and run:
$ sudo k3s kubectl get node -o wide
You should see all of your nodes broadcasting a Ready status.
Happy cattle herding!