Ubuntu 20.04, Rancher and Raspberry Pi

Published by moxlotus on


It has been a while since I purchased my Raspberry Pi 4. There was not much success in my previous attempts in getting rancher to run. The reason is due to incompatibility between Raspbian and Rancher. With the release of Ubuntu 20.04 LTS last month, I decided to try to explore setting up pi cluster again, but using Ubuntu this time.
And here it is! A guide to set up everything.

If you encountered any issues, do refer to the FAQ below.

Hardware used in this guide

  1. 4 X Raspberry Pi 4B 4G
  2. 1 X Debian Machine (this is used to run Rancher Server)

The Steps

Follow the guide below on how to install Ubuntu 20.04 onto Raspberry Pi.
Install Ubuntu on Raspberry Pi 4

Add the following to /boot/firmware/cmdline.txt

cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1

check that cgroup memory and cpuset are being enabled

$ cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset  2       10      1
cpu     7       51      1
cpuacct 7       51      1
blkio   11      51      1
memory  4       114     1
devices 9       51      1
freezer 3       11      1
net_cls 6       10      1
perf_event      5       10      1
net_prio        6       10      1
pids    10      56      1
rdma    8       2       1

Change the hostname so that each raspberry pi has an unique identifier

$ sudo vim /etc/hostname

I have named mine, rpi-1 to rpi-4


Install Docker onto all the machines. You may follow the guide from docker hub below.
Docker Installation Guide

After docker has been installed, run the following command to launch Rancher Server (For performance reason, this is preferrably done on a dedicated machine other than raspberry pi)

$ docker run -d --restart=unless-stopped -p 8080:80 -p 8443:443 rancher/rancher:v2.3.5

Once your rancher server has successfully launched, open your browser and enter https://<your.ip>:8443/
WARNING: Do not use localhost or 127.0.0.1. If you did use that to open the page, please use your host ip for the URL when prompted to be saved.
dash
Click on Add Cluster and select From existing nodes (Custom)
add_cluster
Select Flannel under network provider and leave everything as default.
add_cluster
Click Next to add an etcd and controlplane. WARNING: DO NOT ADD WORKER YET
nodes
After the cluster has been successfully created, you will see something similar to the screenshot below.
nodes
Next, let's add the worker nodes. This step may take a while and you will probably notice this error in your rancher server container log. This is perfectly normal. It will not impact the addition of worker nodes.

2020/05/23 14:07:43 [INFO] Handling backend connection request [c-qsxwk:m-656930d379e4]
E0523 14:08:05.982836       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v3.ClusterAuthToken: Get https://192.168.3.122:6443/apis/cluster.cattle.io/v3/watch/namespaces/cattle-system/clusterauthtokens?allowWatchBookmarks=true&resourceVersion=920&timeout=30m0s&timeoutSeconds=479: dial tcp 127.0.0.1:6443: connect: connection refused
2020/05/23 14:08:12 [ERROR] failed on subscribe storageClass: Get https://192.168.3.122:6443/apis/storage.k8s.io/v1/storageclasses?resourceVersion=0&timeout=30m0s&timeoutSeconds=1800&watch=true: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:08:35.963845       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1.Deployment: Get https://192.168.3.122:6443/apis/apps/v1/watch/deployments?allowWatchBookmarks=true&resourceVersion=1088&timeout=30m0s&timeoutSeconds=536: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:08:36.008130       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v3.ClusterUserAttribute: Get https://192.168.3.122:6443/apis/cluster.cattle.io/v3/watch/namespaces/cattle-system/clusteruserattributes?allowWatchBookmarks=true&resourceVersion=920&timeout=30m0s&timeoutSeconds=497: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:08:36.437059       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1.ClusterRole: Get https://192.168.3.122:6443/apis/rbac.authorization.k8s.io/v1/watch/clusterroles?allowWatchBookmarks=true&resourceVersion=1111&timeout=30m0s&timeoutSeconds=417: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:08:36.966440       7 reflector.go:123] github.com/rancher/norman/controller/generic_controller.go:193: Failed to list *v1.Deployment: Get https://192.168.3.122:6443/apis/apps/v1/deployments?limit=500&resourceVersion=0&timeout=30s: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:08:37.968963       7 reflector.go:123] github.com/rancher/norman/controller/generic_controller.go:193: Failed to list *v1.Deployment: Get https://192.168.3.122:6443/apis/apps/v1/deployments?limit=500&resourceVersion=0&timeout=30s: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:09:05.950401       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1.Endpoints: Get https://192.168.3.122:6443/api/v1/watch/namespaces/cattle-prometheus/endpoints?allowWatchBookmarks=true&resourceVersion=1225&timeout=30m0s&timeoutSeconds=486: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:09:35.975039       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1beta1.CronJob: Get https://192.168.3.122:6443/apis/batch/v1beta1/watch/cronjobs?allowWatchBookmarks=true&resourceVersion=1&timeout=30m0s&timeoutSeconds=374: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:09:36.959433       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1.Endpoints: Get https://192.168.3.122:6443/api/v1/watch/namespaces/cattle-prometheus/endpoints?allowWatchBookmarks=true&resourceVersion=1669&timeout=30m0s&timeoutSeconds=427: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:10:07.465674       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1beta1.Ingress: Get https://192.168.3.122:6443/apis/extensions/v1beta1/watch/ingresses?allowWatchBookmarks=true&resourceVersion=1&timeout=30m0s&timeoutSeconds=423: dial tcp 127.0.0.1:6443: connect: connection refused
E0523 14:10:36.455139       7 reflector.go:280] github.com/rancher/norman/controller/generic_controller.go:193: Failed to watch *v1.ConfigMap: Get https://192.168.3.122:6443/api/v1/watch/namespaces/cattle-system/configmaps?allowWatchBookmarks=true&resourceVersion=845&timeout=30m0s&timeoutSeconds=478: dial tcp 127.0.0.1:6443: connect: connection refused

Congratulation! You very own Kubernetes cluster is now up and running. Now it's time to deploy an App!
nodes
nodes

FAQ
Q: Worker taking forever to register
A: Delete /var/lib/kubelet/ and try again.

Q: error "tls: failed to verify client's certificate: x509: certificate signed by unknown authority (possibly because of \"crypto/rsa: verification error\" while trying to verify candidate authority certificate \"kube-ca\")", ServerName ""
A: Delete /etc/kubernetes and try again

Q: Is Rancher/Rancher:v2.3.5 the only version I can use
A: No, I have tried Rancher/Rancher:v2.4-head which works fine too.

Share it with others

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *