Best Practices for Deploying Docker Swarm Clusters on Alibaba Cloud

Docker ecosystems witnessed quick development and maturity in 2016. The 2016 China Container Technology Research Report detected that most users in China are interested in Docker technology and 80 percent of them will consider the application of container technology.
This article will provide information on how to utilize resource orchestration for the deployment of Docker swarm clusters.

First, Docker 1.12 needs to be installed. It provides the swarm mode to turn a group of Docker engines into a single, virtual Docker engine for unified management and scheduling. The following figure shows the cluster architecture:

If you have already deployed the VPC network and NAT gateway, skip Step 1, and go to Step 2.
● Step 1: Create a VPC network and NAT gateway. There are multiple ways to create a NAT gateway. Choose as per your service scenario. This article describes the method of binding an elastic IP (EIP) address by using the ECS and creating the SNAT gateway by adding a custom route. You can refer the enterprise-level public network VPC gateway released by Alibaba Cloud.
Run the template, construct a SNAT Gateway as provided by Alibaba Cloud. Choose your location and region. Then, enter the associated parameter values.
In this step, the EIP address, VPC, router, custom route, VSwitch, security group, and SNAT gateway are created.

You can click Enter Event List to check the resource creation process. After the resource stacks are created, click Output in Overview to check the information about the VPCID and VSwitchID, which are required for creating the Docker cluster in Step 2.

● Step 2: Create a Docker cluster by running the One-key Creation of Docker Swarm Cluster template provided by Alibaba Cloud. Choose a value for Region, which is the same value for the VPC. Enter the associated parameter values based on the following guidelines:
• Use an existing VPCID and VSwitchId. Their values can be checked via output results in Step 1.
• The value of ECSZoneID should be consistent with the ZoneID of the VSwitch.
• Utilize 64-bit mirroring of the OS through Alibaba Cloud. Ubuntu is recommended. For other OSs, you need to modify associated commands in the User Data section of the template.
• Fill in the number of Masters and Workers. The template will automatically create one Master. Therefore, if the number of Masters is set to 2 and the number of Workers is set to 3, the created cluster will have two Master nodes and three Worker nodes.

● Step 3: Remotely log on to the Docker Master host, and run the Docker node ls. You will see six nodes (created in Step 2).

Conclusion

In this article, we discussed some of the best practices for deploying Docker swarm clusters on Alibaba Cloud through resource orchestration. The steps involved in this deployment were explained for easy understanding.