How to deploy a docker swarm cluster using azure container service?
Docker Swarm is a native Docker container orchestrator that allows us to see a group of Docker hosts as a single Docker Engine. Azure Container Service provides a complete platform for running Docker Swarm and makes it simple for teams to instantly spin up clusters, and define access control policies.
Users have the ability to create and configure Docker clusters on Azure from the easy to use Azure web portal interface or Azure CLI. In this post I will show you how to deploy a docker swarm cluster using azure container service on Azure Portal.
In order to login to azure portal, you need to have an azure account and azure subscription. Browse to http://portal.azure.com and log in to the portal. After login to the portal, click on the green plus at top left corner and search for azure container service.
In result view, click on Azure Container Service.
Then, click on the Create button. A new page will open for you to configure your new cluster. In the basic section, select Swarm from the orchestrator drop down list. As you can see there are other options like DC/OS and Kubernetes available.You also have to choose the Azure subscription, a resource group and the geographically location where the cluster will be deployed. Click OK to go to step 2.
In this step, you have to set some settings for Azure Container Service, like the number of masters, DNS name prefix for the cluster and user name that will be administrator of the virtual machines. Paste your SSH public key and define number of masters. You may want to enable VM diagnostics.
In step 3, you would enter number of agents and also size of your cluster.
After selecting the size of your cluster, click OK and wait for the final validation.
Once the validation is completed, you can also download the Azure Resource Manager template that has been generated by the portal. You will be able to use this template if you want to deploy another cluster using Azure CLI or PowerShell.
Click ok and the deployment starts and it takes a couple of minutes to be completed.
Once the deployment is completed, you can access your new Azure Container Service.
In the essentials pane, click on the link below the deployment to get more information about it.
In the deployment history, click on the last entry to get the deployment’s information.
It displays a summary of the cluster and you can also get the ssh command that will allow you to connect to the master nodes.
In order to connect to the swarm master is really simple using the SSH command in the output information produced by the deployment. If you are on Linux, open a terminal. Paste the command copied from the portal:
Once connected, you can use the docker command to work with your Swarm cluster. The Docker Swarm socket is listening to the 172.16.0.5:2375 . You can type docker info with the -H option to get information about your Swarm cluster.
Now let’s start a new container on the cluster, you can type the following command:
docker -H 172.16.0.5:2375 run -d -p 80:80 nginx
And now let’s get the active container using docker ps command.
We can test that NGINX server is working by browsing to the public IP address of the agents’ load balancer. In order to get this ip address, browse to the swarm agent ip address in the Azure portal, and copy the public IP address of the agents as below:
Paste this ip address to your browser and it takes to the welcome page of nginx.
Number of Views:1048