Giter Site home page Giter Site logo

pizero-docker-demo's Introduction

DockerCon 2016 Hack

Live IoT cluster demonstration

Load-balanced Python flask service with LED lights to show when an upstream server is being utilized. This is designed to be both educational and to serve as an example of what can be done when combining Docker with the Raspberry PI.

Honoured to have had this retweeted by Solomon Hykes, the creator of Docker

Technical Deep Dive

Please read the technical Deep Dive here on my blog for all the details and conceptual diagrams.

Watch me on Pimoroni's live YouTube TV show

In Bilge Tank 039 - Clusters, Docker, Brambles & Raspberry Pi Supercomputers! I talk Docker, what it means to be a Docker Captain and all about Docker Swarm. I also demo the full Hack with an additional Raspberry Pi board making 5 nodes in total.

BilgeTank 039 on YouTube

Watch the demo

Click link for video

In the video I give a quick explanation of the setup then use curl and Apache Bench ab to simulate a real-world load on the cluster.

View Demo on YouTube

Installation / configuration

Step 1

Start the Swarm manager

$ git clone https://github.com/alexellis/pizero-docker-demo.git
$ cd pizero-docker-demo
$ cd consul
$ ./start_consul.sh
$ ./manage.sh

Step 2 Start Swarm agents

Perform this step on each Raspberry PI. It must have Arch Linux ARM (ALARM) installed and Docker before going any further.

Install Arch Linux ARM and Docker

$ git clone https://github.com/alexellis/pizero-docker-demo.git
$ cd pizero-docker-demo
$ cd join
$ ./auto_join.sh

I use a shell script called run.sh for this to make running multiple commands easier.

./consul_/agent_run "cd pizero-docker-demo/join && ./auto_join.sh"

View run.sh

To enable all the clustering features we have to specify a KVP store for each of our agents. This will be the consul instance we started on the manager.

Edit /usr/lib/systemd/system/docker.service and update the ExecStart line:

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2375 --cluster-advertise eth0:2375 --cluster-store consul://192.168.0.100:8500

Important note: tcp://0.0.0.0:2375 is insecure and should only be used with an air-gap or in an isolated dev environment. It means anyone with access could potentially run any code on your machine.

Step 2b Assign static IP addresses to your nodes (optional)

Edit /etc/systemd/network/eth0.network and replace it with the following (change the IP address):

[Match]
Name=eth0

[Network]
Address=192.168.0.101/24
Gateway=192.168.0.1
DNS=8.8.8.8
IPForward=ipv4

Step 3 Start the IoTNode containers and Nginx

$ ./start_lights.sh 

Use curl to access the Nginx instance or ab to add some load such as:

ab -c 1 -n 100 http://192.168.0.100/

Feedback or questions?

Send me a tweet at @alexellisuk

pizero-docker-demo's People

Contributors

alexellis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.