Here comes the most awaited feature of 2017 – “Building Docker Swarm cluster which includes all Windows cluster, or a hybrid cluster of Linux and Windows machines, or all Linux systems”. With the inclusion of the recent Docker 17.03 overlay networking feature for Windows Server 2016, it’s now possible to create swarm clusters that include both Windows and Linux environment across the both public and private cloud infrastructure.
Today most of the enterprises manage a diverse set of applications or workloads that might includes both traditional applications & microservices, built on either or both of Linux and Windows platform. Docker now provides a way to modernize all these different applications by packaging them in a standard format which does not require software development teams to change their code. Organizations can containerize traditional apps and microservices and deploy them in the same cluster, which includes both Linux & Windows environment.
Building Hybrid Docker Swarm Mode Cluster Environment
Under this blog post, I will showcase how to build the hybrid Docker Swarm Mode cluster. I will be leveraging Google Cloud Platform where I have 2 Windows Server 2016 & 1 Ubuntu 16.04 instance up and running.
Setting up Windows Server 2016 with Docker 17.03 Enterprise Editio
- Bring up Windows Server 2016 instance on Google Cloud Platform
- Setup Windows password using the below command and then proceed to download the RDP file
- Open up the RDP file downloaded under step-2 and connect to the instance remotely.
- Just 3 commands and docker should be up and running on Windows Server 2016
This should restart the Windows instance and you should be able to see Docker up and running once it comes back.
One can easily verify if Docker 17.03.2 EE is up and running using the below command:
Configuring Windows Server 2016 as Docker Swarm Manager Node:
Run the below command to make this node as a Swarm master node:
Listing the Swarm Mode cluster nodes:
As of now, there is only 1 manager node which gets listed.
Joining Windows Server 2016 as the first Worker Node
Install Docker 17.03 EE on the 2nd Windows Server 2016 instance and issue the below command to join it as worker node:
Listing out the Swarm Mode cluster:
Adding Linux System to the Cluster
Login to Ubuntu 16.04 instance, install Docker 17.06 and then issue the below command to join it as 3rd node to the existing cluster:
Wow ! This builds up our first hybrid Swarm Mode cluster which includes 2 Windows nodes & 1 Linux Nodes.
A Quick way of verifying the OS type:
Create an Overlay Network For Swarm Cluster
Before we start deploying application, we need to create an overlay network which spans across the cluster nodes. By default, it shows up the below listed network drivers:
As shown above, it displays 3 different networks – nat, none and ingress. Let us create a new overlay network ‘collabnet’ using the below command:
Creating our First Windows-based Service container
It’s time to create our first service. I will pick up MSSQL container which will use ‘collabnet’ overlay network and should get deployed only on Windows platform based on applied constraint as shown below:
Ensure that you have db-credentials.env under the same directory with the below content:
Once you create service, you can verify it up and running with the below command:
Scaling the DB service
Let us scale the DB service and see if it still applies only to Windows Platform:
As shown above, there are now 3 instance of the same application up and running. The MS SQL is now running on only Windows system based on the constraint specified.
Creating Linux specific applications
Let us create a Web application having frontend as WordPress and backend as MySQL container with a constraint that it should get deployed only on Linux specific platform.
Hence, we saw that MS SQL service is running on Windows host instance while WordPress application specific to Linux is successfully up and running on Linux nodes which proves that the newer Swarm Mode comes with an ability to intelligently orchestrate across mixed clusters of Windows & Linux worker nodes.
Adding Linux Worker Node and promoting to Manager
You should be able to view the list of nodes from Ubuntu manager node too:
In case you are looking out for application which uses frontend application running on Windows platform whereas the backend application uses Linux, here is a quick example.
Did you find this blog helpful? Feel free to share your experience. Get in touch @ajeetsraina.
If you are looking out for contribution/discussion, join me at Docker Community Slack Channel.