Skip to content

Instantly share code, notes, and snippets.

@dhet
Last active November 29, 2017 16:06
Show Gist options
  • Save dhet/6ef59d49b25efb6c54cebe1c39cca41e to your computer and use it in GitHub Desktop.
Save dhet/6ef59d49b25efb6c54cebe1c39cca41e to your computer and use it in GitHub Desktop.
Docker swarm for Raspberry Pi cluster

Challenges

Services are incompatible with the nodes

By default, docker swarm will assume that a service will run on x86 systems and accordingly set the services target platform to amd64. In the case of our raspis, this results in an error ("no suitable node") when inspecting the service execution list. This problem can be circumvented by specifying the --no-resolve-image flag when running docker service create.

Specifying which node a service may run on

In order to specify compatibility between nodes and services two things need to be done

  1. The node needs to be specified with a label. This can be done when running docker node create by specifying the tag --label cam=true. When updating the node: docker node update --label-add cam=true.
  2. The service needs to have a constraint. A constraint may be added via docker service create --constraint 'node.labels.cam==true' .... When updating a node: docker service update --constraint-add 'node.labels.cam==true'

Error: "memory cgroup not supported on this system: unknown"

When inspecting running instances of a service we were getting this error. Solution suggested here worked: on the worker node, add cgroup_enable=memory cgroup_memory=1 to the /boot/cmdline.txt and reboot.

Set up an overlay network

sudo docker network create -d overlay --attachable pi-net

Service creation

sudo docker service create --network=pi-net --constraint='node.labels.motor==true' --no-resolve-image --name publisher kugele1337/messenger-pub
sudo docker service create --network=pi-net --constraint='node.labels.cam==true' --no-resolve-image --name subscriber kugele1337/messenger-sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment