Kubernetes (commonly stylized as k8s) is an open-source container-orchestration system for automating application deployment, scaling, and management. (cited from Wikipedia)
MicroK8s is only available for 64-bit Ubuntu images.(Cited from How to build a Raspberry Pi Kubernetes cluster using MicroK8s: Setting up each Pi)
- k3s, k3d, k3d
|supported architectures||AMD64||AMD64||AMD64, ARMv7, ARM64|
|supported container runtimes||Docker, CRI-O, containerd, gVisor||Docker||Docker, containerd|
|startup time: initial/following||5:19 / 3:15||2:48 / 1:06||0:15 / 0:15|
|memory requirements||2GB||8GB (Windows, MacOS)||512 MB|
|requires root?||no||no||yes (rootless is experimental)|
|multi-cluster support||yes||yes||no (can be achieved using containers)|
Here in my case, I’m going to use k3s to manage and monitor the cluster. The following 2 blogs are strongly recommended from me.
- Run Kubernetes on a Raspberry Pi with k3s
- Kubernetes 1.18 broke “kubectl run”, here’s what to do about it
Let’s take a look at the IP info of ALL 4 Raspberry Pis. Let’s take pi04 as the example this time. pi01, pi02, pi03 are having very similar IP info as pi04.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
As mentioned in A Cluster of Raspberry Pis (1) - Configuration, pi04 is an old Raspberry Pi 3 Model B Rev 1.2 1GB, which is unfortunately with a broken Wifi interface wlan0. Therefore, I’ve got to insert a Wifi dongle in order to have Wifi wlan1 enabled.
3. k3s Installation and Configuration
3.1 k3s Installation on Master Node pi01
pi@pi01:~ $ curl -sfL https://get.k3s.io | sh -
If we take a look at IP info, one additional flannel.1 interface is added as follows:
4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default
3.2 k3s Installation on Work Node pi01, pi02, pi03
Before moving forward, we need to write down node token on the master node, which will be used while the other work nodes join in the cluster.
pi@pi01:~ $ sudo cat /var/lib/rancher/k3s/server/node-token
pi@pi0X:~ $ curl -sfL http://get.k3s.io | K3S_URL=https://192.168.1.253:6443 \
, where X=2, or 3, or 4.
pi@pi01:~ $ sudo kubectl get nodes
3.4 Access Raspberry Pi Cluster from PC
✔ kubectl get nodes
We can even specify the role name by the following command:
✔ kubectl label nodes pi0X kubernetes.io/role=worker
, where X=2, or 3, or 4.
Let’s take a look at all nodes again:
64 ✔ kubectl get nodes
73 ✔ kubectl create deployment nginx-sample --image=nginx
After a while, nginx-sample will be successfully deployed.
79 ✔ kubectl get deployments
Now, let’s expose this service and take a look from the browser:
82 ✔ kubectl expose deployment nginx-sample --type="NodePort" --port 80