Quick setup of #microk8s on #raspberrypi4.

Lets setup one node cluster for development or playing around with Kubernetes on Raspberry Pi 4. I have used Ubuntu 19.10 images for Raspberry Pi 4, which are available for download at: ubuntu-rpi. Assuming you have your rpi up and running, lets switch to installing Microk8s.

Step 1: Enable memory cgroup

1
# emacs /boot/firmware/nobtcmd.txt

And add:

1
cgroup_enable=memory cgroup_memory=1

After rebooting should see ‘1’ (enabled):

1
2
# grep mem /proc/cgroups | awk '{ print $4 }'
1

Step 2: Install microk8s

1
2
3
4
# snap install microk8s --classic --channel=1.17/edge
# usermod -aG microk8s ubuntu
# microk8s.enable dns dashboard storage
logout/login

Start microk8s and check status:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ microk8s.start
$ microk8s.status
microk8s is running
addons:
cilium: disabled
dashboard: enabled
dns: enabled
fluentd: disabled
gpu: disabled
helm: disabled
ingress: disabled
istio: disabled
jaeger: disabled
juju: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metallb: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: enabled

Step 3: Login to dashboard (if you’re ssh’ed to rpi from your machine)

This is not recommended setup for dashboard, but for local test should be fine. On your machine perform local port forwarding:

1
$ ssh -L 8001:localhost:8001 [email protected]

On rpi setup proxy:

1
$ microk8s.kubectl proxy --accept-hosts=.\* --address=0.0.0.0

From your machine open dashboard:

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#/login

Get login token from rpi:

1
2
$ token=$(microk8s.kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
$ microk8s.kubectl -n kube-system describe secret $token

That’s it, you could start developing your apps on Kubernetes, or just play around with Kubernetes itself. If you have more rpi’s — setup a cluster! Microk8s docs available at: https://microk8s.io/docs/