K8S on RPi

If you don’t want to pay extra for hosting Kubernetes services you can setup your own Kubernetes cluster on Raspberry Pi platform.

First you need to download and install OS on RPi. If you can connect display and perypheria you can use Raspbian desktop edition, but if you are fine with shell only try headless. Raspbian downloads are available here.

To automate WiFi and SSH connection after OS installation navigate to boot directory and create wpa_supplicant.conf file and place the code:

country=PL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid="YOUR_WIFI_NAME"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

After start file will be moved to location: /etc/wpa_supplicant/

In the same directory create empty ssh file using command below:

touch ssh

Then boot up your RPi and check on the router IP address assigned to RPi

Connect to RPi

ssh pi@<rpi_ip>

Remeber to change default password for pi user

sudo passwd

Then you can install git, k8s

sudo apt update
sudo apt install git
curl -sfL https://get.k3s.io | sh -

Download your Kubernetes YAML code from your git repository and allow RPi user to connect to repository (in my case GitHub)

Now you can create your first Kubernetes node. I’ve done simple RabbitMQ instance

sudo kubectl apply -f <your_app_service_and_deployment>.yaml

It works nice! 🙂