If you’ve followed my blog or seen me presenting in the last six months you may have noticed I have developed a keen interest in Cloud Native Apps and DevOps in general. I was lucky enough to present a combined CNA/vCloud Air session at VMWorld this year which was a little different from the hybrid cloud talks I usually give.
In addition to the ‘what-why-how’, I also ran a live demo showing the provisioning and decommissioning of a remotely accessible VCA Docker host, complete with NAT and firewall configuration using two simple commands. Since Las Vegas I have been meaning to post how I constructed the demo, so here it is.
Note: some prior knowledge of basic vCloud Air administration and Docker functionality is assumed…
Docker Machine Driver for vCloud Air
In my previous post I talked about VM’s and containers living side by side as decomposing (or building alongside) monolithic apps can take an extended period of time, or may not be possible at all. To support this notion, VMware has made great strides in the containers space to provide technology that allows organisations to run containers natively on vSphere (through VIC) or Photon Platform depending on operational requirements and overall maturity with the cloud native apps.
However there is one aspect of the VMware CNA vision that is often overlooked, namely vCloud Air. This may be because vCloud Air does not have a native container offering (at the time of writing this post), but it does have support for Docker Machine which is an essential part of the Docker workflow if using Docker Toolbox for administration.
What do we need?
In order to use the Docker Machine Driver for vCloud Air we will need to have a VCA subscription (either Virtual or Dedicated Private Cloud) and a user account with network & compute administrator permissions assigned. With this we can go ahead and create a private template which Docker Machine will use to create our container host. Note, if not specified in our docker-machine create command, Docker Machine will use Ubuntu Server 12.04 LTS from the VCA Public Catalogue by default.
Quick Tip: To create a quick template I used the Ubuntu Server 12.04 LTS image from the VCA Public Catalogue as it already has VMware tools installed. After I ran my usual VCA linux template prep, (root pw change, network config, ssh config, apt-get upgrade, apt-get update, etc) I renamed vchs.list to vchs.list.old found in /etc/apt/sources.list.d/. Now I did this because when Docker Machine runs through the provisioner process it uses apt-get to retrieve VCA packages from packages.vmware.com, which can sometimes be a little slow to respond. This occasionally results in the provisioner process timing out (as it did in my demo at VMWorld….grrr). Note, post initial template creation it is not necessary to have the packages.vmware.com repo available for the docker provisioning process.
Provided we have a access to a VCA routable network and an available public IP address, we can go ahead and run a relatively simple shell script to execute the entire provisioning process. It should be noted that I created this script to be easily distributed to anyone needing quick access to a docker environment, provided they had the correct VCA permissions. It also avoids storing your VCA password in clear text.
#Simple docker-machine VCA docker host creation script read -p "Enter VCA user name: " USER echo Enter VCA Password: read -s PASSWORD echo docker-machine create --driver vmwarevcloudair \ --vmwarevcloudair-username="$USER" \ --vmwarevcloudair-password="$PASSWORD" \ --vmwarevcloudair-vdcid="M123456789-12345" \ --vmwarevcloudair-catalog="KGLAB" \ --vmwarevcloudair-catalogitem="DMTemplate01" \ --vmwarevcloudair-orgvdcnetwork="KGRTN01" \ --vmwarevcloudair-edgegateway="M123456789-12345" \ --vmwarevcloudair-publicip="x.x.x.x" \ --vmwarevcloudair-cpu-count="1" \ --vmwarevcloudair-memory-size="2048" \ DockerHost01
The expected output is as follows…
Note, this is a minimal subset of commands for basic VCA container host provisioning. I have also changed the VDC ID, Edge Gateway ID and public IP in the example script for obvious reasons. A full list of Docker Machine Driver for vCloud Air commands can be found on the Docker website here.
Once the provisioner process is complete, we should have an internet accessible container host configured with 1 vCPU, 2GB of memory with Docker installed, running and listening for client commands on the configured public IP we specified earlier.
To natively connect to this environment from our Docker client we simply enter the following…
~> eval (docker-machine env DockerHost01)
That was easy, right? Well… it’s not quite that simple.
The above will create a relatively insecure Docker environment as the edge firewall rules are not locked down at all (as shown below).
This can be handy for testing internet facing containers quickly as we do not need to explicitly define and lock down the ports needed for external access. However if this Docker host is intended to become a even a little more permanent, we can use VCA-CLI or the VCA web/VCD user interface to alter the rules (at a minimum port 2376 needs to be open from a trusted source address for client-server communications, and whatever ports are needed to access containers directly from the internet).
Assuming our environment is temporary, we can also tear it down quickly using:
~> docker-machine rm DockerHost01
So there you have it. The entire build provisioning process takes less than 5 mins (once you have set up a template) and decommissioning takes less then 2 mins! In addition to simple tasks I’ve outlined here we can also use a similar process to create a Docker Swarm cluster, which I will cover in my next post.
As always, if you have any questions or feedback feel free to leave a comment or hit me up on Twitter.