Kubernetes Cluster with Raspberry Pis Print


This is the first post in our Pi-IoT post series.


Credit where Credit is Due

I owe a big thanks to the fine folks over at Hypriot for all their work in this area. Their initial post on this subject was a good starting point but has become stale and incorrect due to some critical updates with docker and kubernetes.

Flash HypriotOS on your SD cards

You can find the latest release at HypriotOS. They also provide a pretty handy flash tool which you can use like:

The --hostname enterprise is the name given to the Pi. You can also add other parameters. You can add WIFI information if you are using WIFI for your network. -s YOURSSID -p YourNetworkPassord.

After flashing the OS to the SD cards, install them in your Pi’s, boot them up and log in via SSH

with a default password of hypriot

Install Kubernetes

To install kubernetes, we will add the official APT kubernetes repository on each node. This will require root privileges. Using sudo you can set your user to root like


then just install kubeadm on every node

Living on the bleeding edge always has consequences

In Docker 1.13, a default iptables FORWARD policy was changed from ACCEPT to DROP (#28257). This change causes an issue with published kubernetes services (#40349).

Until kubernetes/flannel catch up with the docker changes, we need to find a workaround. I am opting for creating a systemd service which simply modifies the iptable rules after kubelet and docker have made their changes. When this issue is fixed, we can disable or remove the service.

Initialize Kubernetes on the master node

  • --pod-network-cidr – This option is needed because we are using flannel to provide virtual subnets for kubernetes. We use the provided subnet because the flannel configuration file that we use predefines the equivalent subnet.
  • If you are using the WIFI network instead of ethernet, you need to add --apiserver-advertise-address where is changed to the actual IP address on your network of the master Pi. You can find this by running:

After Kubernetes has been initialized, the last lines of your terminal should look like this:


On the master node, exit su and by running the commands below you can now start using your cluster as a regular user:

On each other node, execute the kubeadm join command given in the output to join the cluster. (Note: master node’s hostname can be used instead of IP). It will look something like:

After some seconds, you should see all nodes in your cluster when executing the following on the master node:

Your terminal should look like this:


As of version 1.6.0, We will need to apply the network driver before the nodes will become useable.

Setup flannel as the Pod network driver

As of version 1.6.0, RBAC roles need to be setup for flannel

Run this on the master node:

Your terminal should look similar to this:


Wait until all flannel and all other cluster-internal Pods are Running before you continue.

Check the status by:


Now we have a working kubernetes cluster running on our raspberry pis.

Next post, let’s test our cluster with a simple deployment