Deploy a full Docker Swarm cluster on Azure Container Services
Microsoft has announced the availability of Azure Container Services that allows deploying in an easy way in a cluster of virtual machines that can host containers.
Azure Container Services supports two orchestrators for the clusters:
Docker Swarm: It uses the native Docker stack so that a user can directly use Docker commands to deploy Docker containers.
DC/OS: It is a data centre operating system that can run containers in different formats including Docker images. DC/OS is also used to deploy and run on well-known distributed systems such as HDFS, Spark, Kafka, and Cassandra is used to scale by organizations like AirBnb, Twitter, and Netflix.
In this article, we will explain how you can use Azure Container Services to deploy a Docker Swarm based cluster in Azure.
GENERATE AN SSH RSA KEY
Microsoft is working on the implementation of a container technology for the next version of windows server, but Azure Container Service supports only Linux workloads currently, so the user needs an SSH key to connect the cluster once it is created. There are several ways to create a new key, depending on the system the user is running on.
Firstly, the bash scripts are open source and hosted on Github:
https://github.com/avranju/azure-swarm
The two main scripts are:
swarm-up.sh – This brings the cluster for the user.
swarm-down.sh – This breaks down the cluster which is created by the user using swarm-up.sh.
Create a new Docker Swarm cluster on Azure Container Service
A user can create a new Azure Container Service instance using the Azure portal, Azure CLI or PowerShell. In this article, we will focus on Azure Portal.
Go to http://portal.azure.com and log in with your Azure account and click the “+” new button and search for the “container”.
Click on the Azure Container Service in the result view.
Click on the Create button. An assistance will open to help you to configure your new cluster.
Firstly, the user has to enter the name of the user, that will be the administrator of the cluster and pass the SSH public key. The user has to choose the Azure subscription, a resource group, and the location where the cluster will be deployed.
- Click on OK to continue with the step-2. In this step, a user can choose between two orchestrators: DC/OS or Swarm.
- In the next step, the user has to save the settings for Azure Container Service such as number of masters, nodes, the virtual machine size to use and a DNX prefix which will be used in each source that will be created.
- Click on OK and wait for the final validation.
- In the last section, click on Create button. Depending on the number of masters/agents you have asked for, the cluster creation may take a little time.
Once the deployment is completed, a user can access their new Azure Container Service.
Connect to the Swarm master virtual machine:
Connecting to the Swarm master is really simple, by using the SSH command in the output produced by the deployment.
If you are using Linux or Mac, open a terminal. If you are using Windows, then you can continue to use Git Bash that provides an SSH client.
The user will be asked to enter the passphrase and then you are connected to the Swarm master.
Once connected, you can use the Docker command to work with your Swarm cluster. Your Cluster is ready now, you can deploy your first Docker container.
You have now a fully functional Docker Swarm cluster based on Azure Container Service. As you can see the above steps, it is really simple to create a cluster in Microsoft Azure.