https://github.com/benhid/314-swarm
DIY Raspberry Pi (Zero) cluster with Docker Swarm
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Keywords
Repository
DIY Raspberry Pi (Zero) cluster with Docker Swarm
Statistics
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Raspberry Pi (Zero) cluster with Docker Swarm
Stuff you'll need
In this project I'll use:
| Material | Units | Price | | ------------- |:-------------:| -----:| | Raspberry Pi Zero W | x2 | ~10€/each | | Samsung EVO (class 10) 32GB microSD card | x2 | ~13€/each | | 5V 2.4A Dual USB Charger | 1x | ~10€ | | (optional) TP-LINK TL-WR802N Nano router | 1x | ~25€ |
Steps
- Install Raspbian Stretch Lite on each microSD card. I've used the version from 2018-03-13.
- Enable SSH and set up Wi-Fi. In order to do this, insert the microSD into your pc, navigate to
/media/YOUR_USER_NAME/bootand create an emptyshhfile:bash $ sudo touch sshThen, open the other volume and usesudo nano /etc/wpa_supplicant/wpa_supplicant.confto include the following lines:network={ ssid="YOUR_NETWORK_NAME" psk="YOUR_PASSWORD" key_mgmt=WPA-PSK } - Reproduce step 2 on each microSD and turn on all the Raspberry's.
- After 20 seconds, scan your network to find the IP of each Raspberry Pi Zero. You can either access your Wi-Fi router's settings or use:
bash $ sudo nmap -sn 192.168.1.0/24Note: This step is optional if you have set up static IP addresses for all your nodes. - SSH into your nodes (
ssh pi@192.168.1.XYZ) and install Docker. By default the password is raspberry. Then (for each node) run:bash pi@raspberrypi:~ $ curl -sSL https://get.docker.com | shNote: This will take a while! - Only on the first (master) node initialize the swarm by using:
bash pi@raspberrypi:~ $ sudo docker swarm init --advertise-addr 192.168.1.XYZWhere192.168.1.XYZis the IP of the current node. This will generate a command that will be used to add the rest of the nodes to the swarm. - SSH into the rest of the nodes and run the command produced on the previous step to connect the swarm.
- On the master node (the one from step 6), run:
bash pi@raspberrypi:~ $ sudo docker node lsto check all the nodes on the swarm. You can create a swarm of one manager node, but you cannot have a worker node without at least one manager node. This means that we'll have to promote our second node to a manager:bash pi@raspberrypi:~ $ sudo docker promote NODE_ID Node NODE_ID promoted to a manager in the swarm.
Now, let's create a service in our swarm with docker service create:
bash
pi@raspberrypi:~ $ sudo docker service create \
--name viz \
--publish 8080:8080/tcp \
--constraint node.role==manager \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
alexellis2/visualizer-arm:latest
This will build and start an image with just one replica:
pi@raspberrypi:~ $ sudo docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
xxxx viz replicated 1/1 alexellis2/visualizer-arm:latest *:8080->8080/tcp
To scale that image, run:
pi@raspberrypi:~ $ sudo docker service scale viz=4
At this point you should be able to visit 192.168.1.XYZ:8080 to see a nice swarm visualizer:
Congrats!
Owner
- Name: Antonio
- Login: benhid
- Kind: user
- Location: Málaga, Spain
- Company: University of Málaga
- Website: https://benhid.com/
- Repositories: 24
- Profile: https://github.com/benhid
Software / DevOps Engineer and Researcher @KhaosResearch
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0