https://github.com/benc-uk/pikube
Building a Kubernetes cluster on the Raspberry Pi
https://github.com/benc-uk/pikube
kubernetes kubernetes-cluster raspberry-pi
Last synced: 10 months ago
JSON representation
Building a Kubernetes cluster on the Raspberry Pi
- Host: GitHub
- URL: https://github.com/benc-uk/pikube
- Owner: benc-uk
- Created: 2020-05-27T19:08:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-05T16:39:15.000Z (almost 2 years ago)
- Last Synced: 2025-03-19T05:42:48.720Z (10 months ago)
- Topics: kubernetes, kubernetes-cluster, raspberry-pi
- Language: Python
- Homepage:
- Size: 6.18 MB
- Stars: 17
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Project PiKube
_Project PiKube_ is a slightly grandiose title for my personal guide to building your own Kubernetes cluster, using a small number of Raspberry Pis. This is a "bare metal" approach and we'll be installing & setting up Kubernetes from scratch, how exciting!
If you've never used Kubernetes before, this will probably not be a good starting point, I suggest getting some familiarity before you begin (try kind, k3s or minikube). You will also need to be reasonably Linux/Unix savvy

Updated Feb 2024: This guide was (re)written for Raspberry Pi OS Debian 12 aka Bookworm, and Kubernetes 1.29
# 🚩 Pre-reqs
## Hardware
I am not going to provide a full bill of materials for what you need, but at a minimum have at least two spare Raspberry Pi in order to make this worthwhile. For reference this is what I used:
- 3 x Raspberry Pi 4
- 3 x microSDHC cards (I used 32GB, I'm sure 16GB would work too)
- 3 x Short 30cm USB C cables (There's 1000s on Amazon, find one that sells a pack of 3+)
- 1 x [Multi port USB Power block from Anker](https://www.amazon.co.uk/gp/product/B00VTI8K9K)
- 2 x [Cluster case / rack](https://thepihut.com/products/cluster-case-for-raspberry-pi)
I used one Raspberry Pi as a master node, and two as worker nodes
## Software
- A SSH client
- A decent terminal/shell
- [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) (optional but recommended)
# 🍔 Installing the OS
For this part rather than a step by step guide, these steps are very condensed as they don't really involve anything specific to this project. If this is your first time with a Raspberry Pi you might want to get familiar with using it and setting it up first.
- Download Raspberry Pi OS 64-bit lite (headless) edition: https://downloads.raspberrypi.com/raspios_lite_arm64/images/
- Image all SD cards with the official imaging tool https://www.raspberrypi.com/software/
- During the imaging process pick the option to customise the OS; enable WiFi, set hostnames, enable SSH with your own SSH pub-key
- Pick names for your nodes, I went for `master` `node1` and `node2`
- Get all nodes booted and on the network
⚠ IMPORTANT: It's **highly** recommended to set static IPs for all nodes, [see the appendix](#appendix-1---static-ip-on-raspberry-pi-os-bookworm)
Other notes:
- Simply joining the Pis to your home WiFi network works very well. Surprisingly there is no need to use ethernet, or set up a dedicated network or hub for the cluster, of course you can if you wish, this is an exercise left to the reader
- We will do the install of Kubernetes using SSH, so ensure you can SSH into the nodes from your machine either with a password or SSH keys (I would strongly advise SSH keys!)
- You should not need a keyboard or screen connected to the Pis if you enabled SSH and have them on your network (i.e. configured with WiFi) unless something has gone wrong!
# 💾 Base Configuration & Setup (all nodes)
Nearly every command we will be running will require root access, rather than place sudo literally everywhere, you should switch to root user with `sudo su -` for all of the setup, install and initial configuration
Update the OS and install common packages
```sh
apt update && apt -y full-upgrade
apt -y install iptables apt-transport-https gnupg2 software-properties-common \
apt-transport-https ca-certificates curl vim git
```
Disable swap, it's probably not enabled but just in case
```sh
swapoff -a
sudo dphys-swapfile swapoff && \
sudo dphys-swapfile uninstall && \
sudo systemctl disable dphys-swapfile
```
Enable iptables as kube-proxy uses it
```sh
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
```
Enable some kernel modules which are needed
```sh
tee /etc/modules-load.d/k8s.conf <