What is a swarm?
The cluster management and orchestration features embedded in the Docker Engine are built using SwarmKit. Docker engines participating in a cluster are running in swarm mode. You enable swarm mode for an engine by either initializing a swarm or joining an existing swarm. A swarm is a cluster of Docker engines, or nodes, where you deploy services. The Docker Engine CLI and API include commands to manage swarm nodes (e.g., add or remove nodes), and deploy and orchestrate services across the swarm.
I was recently trying to come up with a script that generates the docker swarm cluster – ready to take container work loads on Microsoft Azure. I thought, Azure Container Service (ACS) should already have supported that. However, I figured, that’s not the case. Azure doesn’t support docker swarm mode in ACS yet – at least as of today (25th July 2017). Which forced me to come up with my own RM template that does the help.
What’s in it?
The RM template will provision the following resources:
- A virtual network
- An availability set for manager nodes
- 3 virtual machines with the AV set created above. (the numbers, names can be parameterized as per your needs)
- A load balancer (with public port that round-robins to the 3 VMs on port 80. And allows inbound NAT to the 3 machine via port 5000, 5001 and 5002 to ssh port 22).
- Configures 3 VMs as docker swarm mode manager.
- A Virtual machine scale set (VMSS) in the same VNET.
- 3 Nodes that are joined as worker into the above swarm.
- Load balancer for VMSS (that allows inbound NATs starts from range 50000 to ssh port 22 on VMSS)
The design can be visualized with the following diagram:
The entire scripts can be found into this GitHub repo. Feel free to use – as needed!