[Raspberry Pi] Installing K3S on Ubuntu within Raspberry Pi 4 Model (or B)

K3S on Raspberry Pi

K3S is the certified Kubernetes distribution built for IoT & Edge computing.

Raspberry Pi 4 Model (or B) is your tiny, dual-display, desktop computer …and robot brains, smart home hub, media centre, networked AI core, factory controller, and much more.

Why Use K3s

Perfect for Edge

K3s is a highly available, certified Kubernetes distribution designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances.

Simplified & Secure

K3s is packaged as a single <40MB binary that reduces the dependencies and steps needed to install, run and auto-update a production Kubernetes cluster.

Optimized for ARM

Both ARM64 and ARMv7 are supported with binaries and multiarch images available for both. K3s works great from something as small as a Raspberry Pi to an AWS a1.4xlarge 32GiB server.

Prerequites

Raspberry Pi 4 Model

Raspberry Pi 4 Model (or B ) was released in June 2019[2] with a 1.5 GHz 64-bit quad core ARM Cortex-A72 processor, on-board 802.11ac Wi-Fi, Bluetooth 5, full gigabit Ethernet (throughput not limited), two USB 2.0 ports, two USB 3.0 ports, 2-8 GB of RAM, and dual-monitor support via a pair of micro HDMI (HDMI Type D) ports for up to 4K resolution.

Buy a Raspberry Pi 4 Model B – Raspberry Pi - https://www.raspberrypi.org/products/raspberry-pi-4-model-b/

Install Ubuntu on a Raspberry Pi

Running Ubuntu on your Raspberry Pi is easy. Just pick the OS image you want, flash it onto a microSD card, load it onto your Pi and away you go.

Install Ubuntu on a Raspberry Pi 2, 3 or 4 | Ubuntu - https://ubuntu.com/download/raspberry-pi

Installation

1
2
3
4
5
6
7
8
$ curl -sfL https://get.k3s.io | sh -
# Check for Ready node, takes maybe 30 seconds

# Kubeconfig is written to /etc/rancher/k3s/k3s.yaml

$ sudo k3s kubectl get node
NAME STATUS ROLES AGE VERSION
raspberrypi4g-8g Ready control-plane,master 35h v1.21.4+k3s1

Advance

Manual start

1
$ sudo k3s server

Run on different node

1
2
3
# On a different node run the below. NODE_TOKEN comes from /var/lib/rancher/k3s/server/node-token
# on your server
$ sudo k3s agent --server https://myserver:6443 --token ${NODE_TOKEN}

Uninstall

To uninstall K3s from a server node, run:

1
$ /usr/local/bin/k3s-uninstall.sh

To uninstall K3s from an agent node, run:

1
$ /usr/local/bin/k3s-agent-uninstall.sh

FAQs

error: error loading config file “/etc/rancher/k3s/k3s.yaml”: open /etc/rancher/k3s/k3s.yaml: permission denied

1
2
3
$ k3s kubectl get node
WARN[2021-09-11T13:19:40.835209976Z] Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify kube config permissions
error: error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied

Run command with sudo

1
2
3
$ sudo k3s kubectl get node
NAME STATUS ROLES AGE VERSION
raspberrypi4g-8g Ready control-plane,master 35h v1.21.4+k3s1

References

[1] K3s: Lightweight Kubernetes - https://k3s.io/

[2] Teach, Learn, and Make with Raspberry Pi - https://www.raspberrypi.org/

[3] Kubernetes - https://kubernetes.io/

[4] Buy a Raspberry Pi 4 Model B – Raspberry Pi - https://www.raspberrypi.org/products/raspberry-pi-4-model-b/

[5] Install Ubuntu on a Raspberry Pi 2, 3 or 4 | Ubuntu - https://ubuntu.com/download/raspberry-pi