Installing a Kubernetes 1.4 cluster on Hypriot 1.1.1 with kubeadm

It’s been a while since our last blog post. However, we are back and again working with Kubernetes on a daily basis. This blog post will show you how to set up a Kubernetes 1.4 cluster with HypriotOS 1.1.1 and the new kubeadm tool.


  • A couple of Raspberry Pis (minimum two)
  • A switch to connect the Raspberry Pis
  • Cables for power and network

For this tutorial we used 4 Raspberry Pi 3 and a Macbook Pro.

Flashing the SD-cards

First, flash the SD cards with HypriotOS 1.1.1 using the Hypriot flash tool.

$ flash --hostname master
$ flash --hostname slave01
$ flash --hostname slave02
$ flash --hostname slave03

When the flash of the 4 sd-cards has completed, insert them into the 4 Raspberry Pis and power them up. Make sure you are able to contact the Pis by SSH’ing into them one by one. The default password for the pirate-user is: hypriot

$ ssh [email protected]
$ ssh [email protected]
$ ssh [email protected]
$ ssh [email protected]

After logging into the Pis, exit back to your machine.

Next, we need to set up our SSH-keys:

ssh-keygen -R master.local  
ssh-copy-id [email protected]  

Repeat the above for all the Pis.

Configuring the IPs

To make things easier to handle, I want to change the IPs to static IPs. I chose the IP scheme to be: (master) (slave01) (slave02) (slave03)  

Repeat for all Pis

First SSH into the Pi

$ ssh [email protected]
$ sudo nano /etc/network/interfaces

Replace the content of this file with

auto lo  
iface lo inet loopback

allow-hotplug eth0  
iface eth0 inet static  
address **<YOUR IP GOES HERE>**  

iface eth0 inet6 auto

allow-hotplug wlan0  
iface wlan0 inet dhcp  
pre-up /usr/bin/occi  
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf  
iface default inet dhcp  

Then reboot each device by running

sudo reboot  

Installing Kubernetes

Switch to the root user

sudo -s  

And execute the following, which will add the Kubernetes apt-get respository to the resources.

$ curl -s | apt-key add -
$ cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main  

Notice: Make sure there isn’t a space after EOF.

Update everything

$ apt-get update

Then install the kubeletkubeadmkubectl, and kubernetes-cni

$ apt-get install -y kubelet kubeadm kubectl kubernetes-cni

Setting up the master

kubeadm init --pod-network-cidr=  

The --pod-network-cidr= is needed for flannel to be configured correctly. Flannel is at the moment the only overlay network that works with Raspberry Pis. When the command has finished, (which will take a couple of minues) the output will be similar to the following:

Public: /etc/kubernetes/pki/ca-pub.pem  
Private: /etc/kubernetes/pki/ca-key.pem  
Cert: /etc/kubernetes/pki/ca.pem  
<master/pki> generated API Server key and certificate:  
Issuer: CN=kubernetes | Subject: CN=kube-apiserver | CA: false  
Not before: 2016-11-24 20:25:58 +0000 UTC Not After: 2017-11-24 20:26:02 +0000 UTC  
Alternate Names: [ kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local]  
Public: /etc/kubernetes/pki/apiserver-pub.pem  
Private: /etc/kubernetes/pki/apiserver-key.pem  
Cert: /etc/kubernetes/pki/apiserver.pem  
<master/pki> generated Service Account Signing keys:  
Public: /etc/kubernetes/pki/sa-pub.pem  
Private: /etc/kubernetes/pki/sa-key.pem  
<master/pki> created keys and certificates in "/etc/kubernetes/pki"  
<util/kubeconfig> created "/etc/kubernetes/kubelet.conf"  
<util/kubeconfig> created "/etc/kubernetes/admin.conf"  
<master/apiclient> created API client configuration  
<master/apiclient> created API client, waiting for the control plane to become ready  
<master/apiclient> all control plane components are healthy after 188.931005 seconds  
<master/apiclient> waiting for at least one node to register and become ready  
<master/apiclient> first node is ready after 5.533117 seconds  
<master/apiclient> attempting a test deployment  
<master/apiclient> test deployment succeeded  
<master/discovery> created essential addon: kube-discovery, waiting for it to become ready  
<master/discovery> kube-discovery is ready after 185.528275 seconds  
<master/addons> created essential addon: kube-proxy  
<master/addons> created essential addon: kube-dns
Kubernetes master initialised successfully!
You can now join any number of machines by running the following on each node:
kubeadm join --token=c3625d6ebda8defc  

Should anything fail during the setup, run kubeadm reset, then systemctl start kubelet.service, and try again.

Next, we need to install the cluster network, which as mentioned earlier will be flannel.

$ export ARCH=arm
$ curl -sSL "" | sed "s/amd64/${ARCH}/g" | kubectl create -f -

Verify that the kube-dns pod is running: kubectl get pods --all-namespaces

Setting up the slaves/workers

Copy the command from the output of the master setup and run it on all your workers.

kubeadm join --token <token> <master-ip>  

After a couple of minutes, your Raspberry Pi Kubernetes cluster is ready. Verify with kubectl get nodes on the master pi. The output should be similar to this:

master    Ready     13m  
slave01   Ready     1m  
slave02   Ready     51s  
slave03   Ready     30s  

Getting access to your cluster from you own machine

Make sure you have kubectl installed. Then SSH into the master and open the following file:

$ ssh [email protected]
$ sudo cat /etc/kubernetes/admin.conf

Copy the content of this file to a place on your own machine. I just copy/pasted it in to a file called raspberrypi.conf.

Now, from your local machine you can access the cluster as follows:

$ kubectl --kubeconfig raspberrypi.conf get nodes

Now your Kubernetes cluster is ready to be used! Awesome! 🙂

Leave a Reply

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