Raspberry Pi: Kubernetes vs Swarm Print

Overview

We continue building out our IoT Pi project with a small backtrack.

In a previous post, we created a cluster of Raspberry Pis using Kubernetes. Life with k8s was great until instability set in. It appeared that most of the issues were with the network driver Flannel. we experienced

  • Lost/Unrecoverable nodes
  • Kernel panics
  • Network connectivity issues

We had hopes that the latest version would help with these issues but it appears we may never know as there is a bug preventing flannel from working with our Raspberry Pis.

Swarm to the Rescue

Current versions of Docker include swarm mode. Swarm mode is used for managing a cluster of docker engines called a swarm

Setup

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

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 exposed services

If we run all our applications with the same docker network, this isn’t an issue but for testing purposes we need to find a workaround to hit services from the outside world. I am opting for creating a systemd service which simply modifies the iptable rules after docker has made its changes. When this issue is fixed, we can disable or remove the service.

Initialize the Swarm

Running this on the master node will look like:

The --advertise-flag configures the manager node to publish its address as 10.0.1.202. The other nodes in the swarm must be able to access the manager at that IP address.

Running the join command on a worker nodes results in:

docker node ls on the master node will then show the state of the cluster
docker node ls

Now We Have a Working Docker Swarm Cluster Running On Our Raspberry Pis