The Kubernetes Strikes Back Print

Feeling dissatisfied with the last post, I really wanted to have a working k8s raspberry pi cluster. At the point, I turned my attention to another networking plugin called weave. If you are following along in the series, we are going back to the beginning and rebuilding the cluster.

I had tried weave in the past with no luck but decided to give it another try. My initial install confirmed what I had found before, it just wasn’t working properly but this time I wasn’t ready to give up just yet. After a bit of research, I discovered a couple of problems:

  • A bug in the hypriot install caused all my nodes to have the same machineId (see issue here)
  • Additionally, there was an issue using the hostPort attribute for exposing services. At this point, it was requiring me to use hostNetworking: true in order to expose ports to the outside world. Fortunately, a workaround is available here

With these workarounds documented, let’s setup our RPI cluster.

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

Updating the Machine Id

Now will will apply our first workaround by updating the /etc/machineId
On each node:

then

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

then just install kubeadm on every node

Initialize Kubernetes on the master node

  • If you are using the WIFI network instead of ethernet, you need to add --apiserver-advertise-address 192.168.1.223 where 192.168.1.223 is changed to the actual IP address on your network of the master Pi. You can find this by running:

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

Setup weave as the Pod network driver

Once kubernetes has initialized (and this can take a long time), it’s time to setup weave as the pod network driver

On the master node, simply:

Joining the Cluster

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 similar to this:

Fixing the hostPort Problem

Now lets fix the issue with using hostPort. On each node:

To apply the changes, on the master node, run:

Once

shows everything in a Running state, you now have a working kubernetes RPI cluster.