Building Elder Signs Cluster - Part 3
This is the fourth post in the continued effort to turn six Odroid-MC1 Solos into a PXE booted computer cluster on which to engage in further FOSS hijinks. The focus of this post will be getting a Docker Swarm set up.
Effectively we will be initializing the cluster of docker engines in swarm mode, adding nodes to the cluster.
Overview
The Docker Swarm master machine (MC1_0) will be the swarm manager and node on which the commands to run the swarm.
- Assumption, the following ports are open between all cluster nodes(May need modification according to specifics of a particular setup.)
- TCP port 2377 for cluster management communications
- TCP and UDP port 7946 for communication among nodes
- UDP port 4789 for overlay network traffic
- IPSEC protocol 50 (ESP) is allowed.
Creating the Swarm
On the Docker Swarm Master Node
- Connect to your Swarm master node via ssh. In my set up this is host MC1_0, and done by
ssh mc1_0
- On minion, make bootstrap directory,
docker swarm init --advertise-addr 192.168.1.180
This should result in a display that looks similar to the following:
Add Nodes to Swarm Using Salt
Make note of the docker swarm join command out put on the master node in the previous step. We will use this command to join the remaining nodes to the swarm cluster by issuing this command from my salt master node. You could of course ssh to each node and run the command as well.
- Form the Salt master node issue the following command against all your swarm worker nodes, in my case the command is
sudo salt -L mc1_1,mc1_2,mc1_3,mc1_4,mc1_5 cmd.run 'docker swarm join --token SWMTKN-1-197ovqeh80s5yqyarysgk4w3spw7djscv0r2r5ub1sy1wiaaz0-1nmj5ptmfftfzelnov701kbbg 192.168.1.180:2377'
. The output returned should look similar to this:
Check Swarm Cluster Setup
Issue the following command to make sure the Docker Swarm has been created as expected, docker info|grep -A6 Swarm
. The number of nodes returned should be the sum of the manager and all worker nodes. The output in my case, when run on the Docker Swarm master node, looks like this:
For more informations about the nodes, issue this command, docker node ls
. When run on my master node, the output looks like this:
Testing the Swarm
With a fully formed Docker Swarm cluster, the next thing to do is test that it is working as expected. To do this we will need to deploy a service to the swarm. And to make things easier we will follow the steps outlined in the swarm documentation.
Deploy a Service to the Swarm
On the cluster master node, issue the following command:
Trust but verify using the following command docker service ls
. The output for me looked like this:
Service Inspection
Using the ID of the service deployed on the swarm from above, issue the following command docker service inspect --pretty <SERVICE-ID>
.
Where is Service Running
Find out where the service is running using this command, docker service ps <SERVICE-ID>
.
Scale Service in the Swarm
Increase the number of services from on to six using the following command, docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS>
.
Where Are the Services Running
Find out where the service is running using this command, docker service ps <SERVICE-ID>
.
Clean Up Services From the Swarm
Clean up the test service from the swarm cluster nodes with the following command, docker service rm <SERVICE-ID>
.
Is the Cluster Clean
Check the services are gone from the swarm using docker service ls
.
Next Steps
- Set up Portainer and test functionality.
Enough for now, see you next post.