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

6 Comments

Jeff · October 18, 2020 at 10:12 PM

Good morning. While looking to see if Rancher had been successfully run on an rpi I came across your site and wanted some clarification:
1. You installed rancher on 1 rpi 4??
2. I see this statement: “run the following command to launch Rancher Server (For performance reason, this is preferrably done on a dedicated machine other than raspberry pi)” You didnt install it on an rpi??
3. your next screenshot shows 2 rpi’s running), rpi1 and rpi2
This isnt adding up, so did you install it on an rpi??

    moxlotus · October 21, 2020 at 9:32 PM

    To answer your questions,
    1. The Rancher Server is installed on a separate Debian machine, the 4 rpi are added as worker nodes to perform various roles – control plane, etcd, worker.
    2. Rancher agent is installed on rpi, Rancher Server on Debian. you can install Rancher Server on Rpi too. But it is too slow.
    3. I added 2 nodes first and another 2 nodes later.

Jeff · October 19, 2020 at 12:17 AM

My comment is gone, why?? I was interested in your reply.

    moxlotus · October 21, 2020 at 9:27 PM

    It is just that I have not approve the comments. There are quite a lot of spams. =)

nozkie · October 28, 2020 at 10:11 AM

I am trying do make the same thing on my pi’s but it’s not working. Do i need to install kubernete first before installing rancher or rancher install kubernete along side. thank you.

    moxlotus · November 1, 2020 at 11:23 AM

    k8s will be installed by rancher server. you do not need to worry about that.

Leave a Reply

Avatar placeholder

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