Healthdirect Australia provides all Australians with access to health information and advice, no matter where they live, or what time of the day or night it is, they can talk to a health professional, find trusted advice online about the appropriate care for their health issue and find the closest local services that are open when they need them.
Our Docker journey originally started with the open source edition and early on we invested in building out our own tooling to support infrastructure and application provisioning. Recently we transitioned to Docker Datacenter consisting of Engine, Trusted Registry and Universal Control Plane (which comes with Swarm). Having an integrated end-to-end platform with management, plugins and ecosystem integrations available right out of the box was the deciding factor for us. Docker Datacenter provides us with a solid foundation for our application environment so our team can spend more time directly building or deploying applications that help our customers.
In this blog post we will explain how we use Docker Swarm to do blue green deployments.
At Healthdirect we use Puppet to deploy our Swarm cluster to ensure our cluster is in a consistently defined state each time we deploy. In this example we will be pulling our Docker images from our local Trusted Registry. Our environment is based on AWS but the same approach could be easily ported to any other cloud provider or Openstack, for example. The reason we use an internal registry is to take the advantage of the increased speed we will get at deployment time by having our images close to the endpoints they will be deployed to.
So first of all let’s look at the plumbing: we are going to assume that we have a deployment tool to provision our instances in a build server like Jenkins. As part of the build process the cloud init userdata will bootstrap Puppet onto our nodes.
The environment looks like the following:
To build our Consul cluster we use the following code:
In the above code snippet we will setup our Consul cluster and set up a simple health check to make sure our Docker daemon is healthy. You will notice that we have two blocks of code to set up Consul. The first to bootstrap the cluster, the second to join the cluster.
Next we will set up Swarm with a native Docker network called swarm-private. We will create a private network called swarm-private using the overlay driver. Again we have two blocks of code to set up our Swarm cluster. The first is the block is the master, the second again will give us the functionality to add more nodes to our cluster.
The final code snippet will actually deploy our application to our Swarm cluster. In this instance we have an nginx, application and db Docker images in our Docker Trusted Registry. We will use Puppet to pull our images and deploy them to our cluster.
As you can see we are taking advantage of the native Docker networking stack to lock down access to our database. In a production environment you would want to add scheduling filtering to make sure you have all your containers spread correctly.
Now pictured in the diagram above we have a working Swarm cluster, that is defined and repeatable. When a new build of the application is released we can now build a new Swarm cluster. This is perfect for developers, QA teams and Production as you can deploy blue and green deployments and either repoint your load balancer or DNS.
Make sure to check out the Puppet module for Swarm contributed by Scott himself.
And don’t forget to participate in our DockerCon ticket raffle! Share a picture or description of your Swarm with us on Twitter and tag @docker and #SwarmWeek for a chance to win a free ticket to DockerCon 2016 in Seattle, WA on June 19-21.
- Get started by downloading Docker Swarm and read the docs
- Try Docker Swarm as part of Docker Datacenter
- Submit questions to Docker Forums or file issues in Github
- Contribute to the Docker Swarm project
Learn More about Docker
- New to Docker? Try our 10 min online tutorial
- Share images, automate builds, and more with a free Docker Hub account
- Read the Docker 1.10 Release Notes
- Subscribe to Docker Weekly
- Sign up for upcoming Docker Online Meetups
- Attend upcoming Docker Meetups
- Register for DockerCon 2016
- Watch DockerCon EU 2015 videos
- Start contributing to Docker