It is a simple demo of how to use an arduino UNO to control docker containers on docker swarm cluster with docker remote API. For the demo we used Grove - Starter Kit Plus which contains components listed below.
- Node
- Johnny-five
- Docker swarm
- dockerode module - Docker remote API
Because the demo use Johnny-Five library you need to first install Arduino IDE. It will let you to upload "StandardFirmata" sketch which allows you to communicate through the usb cable between your computer and Arduino microcontroller.
- Download Arduino IDE from the site and install it.
- Run Arduion IDE and from menu "Tools->Board" list select Aruduino/Genuino UNO.
- Connect usb cable to your computer and microcontroller.
- Select from menu "Tools->Ports" a port which you use for communication with arduino.
- From menu select "StandardFirmata" sketch. File->Examples->Firmata->StandardFirmata
- When is opened, upload the sketch. Now you can close Arduino IDE and use Johnny-Five library.
To run the demo you need to first connect all components to Base Shield. Below is description how to connect them.
- RGB Backlight LCD - whichever I2C socket.
- Touch Sensor - D3
- Button - D4
- LED - D6
- Rotary Angle Sensor - A0
- Servo - D5
Next clone the project and install node.
Inside project folder run npm install
Now you need to create docker swarm cluster, for this demo use the guide
When you finish, run the demo using the command npm start
The configuration has the following actions:
- LCD displays active docker image information (Container name, image name, container id, memory usage, cpu usage).
- Button click - switch active container information of LCD screen.
- Touch sensor - runs new image in this case ubuntu one.
- LED - Used to alert when container CPU usage is more than 80%.
- Rotary Angle Sensor - controls servo.
- Servo - it is controlled with rotary sensor. It is only for testing we should use it for something more clever.