Over the past 12 months I have spent many weeks working with customers migrating Linux based workloads to Azure. When we turn up on a customer site we often need to get OSS projects up and running on Azure as quickly as possible. The projects are usually a component of a larger solution that we need to build around as the week progresses.
- Need to get the project up and running to enable developers to start coding,
- Need to deploy multiple instances of the component so that they can be used in parallel,
- Need to be able to easily re-provision a deployment that we have "broken" – i.e. Infrastructure as Code,
- At this point in the week we are not concerned about resilience – we will often look at resilience and performance of these components as the week progresses.
Containers and Docker are now commonplace and many third party applications are now available on Docker Hub either as official or community contributed images. One of the first things I check when I hear of an OSS component is has someone already created a Docker image. Then I use the Azure Docker VM Extension to get it up and running – yes we have lots of other great solutions for running containers, such as Azure Container Service, but at this point we just need to launch the containers with minimum effort and cost.
The extension is reasonably well documented both at the project home on GitHub https://github.com/Azure/azure-docker-extension and on the MS documentation site, https://docs.microsoft.com/en-us/azure/virtual-machines/linux/dockerextension .
GeoServer is an open source mapping server, http://geoserver.org . This was being used by Somerset County Council as part of their public rights of way management system.
A quick search (I used my preferred search engine as it can do a deeper search than via Docker Hub) for an image that is well maintained (searched for the latest version) – "site:hub.docker.com geoserver 2.11" returned a couple of options. I chose https://hub.docker.com/r/winsent/geoserver/ as the Dockerfile is published enabling us to see what has gone into the image.
The next step was to create/acquire an Azure Resource Manager template that deploys an Ubuntu VM. This is a good one to start with https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-simple-linux . By using an Azure Resource Manager template we can quickly redeploy the solution in an identical fashion again and again.
Then we need to edit the azuredeploy.json and if it doesn't already exist add child resources element under the VM properties section. This is where we will place our extension.
The Azure Docker VM extension takes a Docker compose file in JSON format. As we were only deploying a single container this is very straightforward and only needed to specify the image and ports to expose. The JSON for the extension can be seen below:
This needs pasting inside the resource element as indicated earlier. The final template can be reviewed here: https://gist.github.com/marrobi/3c621af940003042dca37d4c6a113fe2 .
When the template is deployed the container can be accessed on the http://vmpublicip:exposed_port. In this case the port exposed was 8080.
As the week progressed we added additional features to the template. Some of which can be found here: https://github.com/marrobi/azure-quickstart-templates/tree/geoserver-docker-ubuntu/geoserver-docker-ubuntu .
Unfortunately the extension only support Linux VMs and containers, maybe on a hack in the future we will find time to modify it so it supports Windows VMs and containers too.