Jake Sanders | 13 April 2015
With the research we've been doing into deploying our services using Docker containers on Apache Mesos, we're always on the lookout for new developments in the Mesos/containerisation space. Recently, the Apache Aurora Mesos framework added preliminary support for Docker containers in their 0.7.0 release, so we had to try it out!
If you've tried to deploy Docker on Mesos before, you've probably heard of Mesosphere's Marathon framework. Why jump to Aurora if it already works? Aurora offers a few more features over Marathon, including an advanced DSL for scripting your tasks and a proven track record in powering Twitter.
Aurora is a Mesos framework, so if you're unfamiliar with the general architecture of mesos, I'd recommend you skim read one of our previous blog posts. However Aurora is a little more complicated than other frameworks - when launching a container it copies its own executor into the container's sandbox, which communicates with the observer, which reports task status back to the scheduler.
This has the unfortunate downside of requiring your container to contain python and mesos native libraries, in return for finer grained process control through Aurora's DSL.
Getting a demonstration cluster up and running should be as simple as installing Virtualbox and Vagrant, then running the following commands:
$ git clone https://github.com/apache/aurora \ cd aurora \ vagrant up
This could take around 15 minutes, so be patient!
In the meantime let's explore aurora's job configuration. Usually called [job name].aurora, they're syntactically valid Python and must contain 3 objects: Job, Task and Process, and a list of Job objects to run called "jobs." If you're using Docker, it should also specify the container image to use. A full example is detailed below, a container that runs 2 processes. Feel free to check out the code from Github.
nginx_proc = Process( name="nginx_process", cmdline="nginx")
consul_template_proc = Process( name="consul_template”, cmdline="consul-template -consul=172.17.42.1:8500 -template "/nginx.template:/etc/nginx/nginx.conf:nginx -s reload"”, max_failures=10)
nginx_task = Task( name = ‘nginx task’, processes = [nginx_proc, consul_template_proc], resources = Resources(cpu = 0.1, ram = 32MB, disk=8MB))
jobs = [ Service(cluster = ‘devcluster’, environment = ‘devel’, role = ‘web-server’, name = ‘nginx’, task = nginx_task, container = Container(docker = Docker(image = ‘registry.livewyer.com/nginx:2015-04-10-1541’)))]
In order to deploy the container on to your aurora cluster, enter your virtual machine running aurora using
vagrant ssh. Create your job file, and run it using the client like so:
$ aurora job create devcluster/web-server/devel/nginx nginx.aurora INFO] Creating job nginx INFO] Checking status of devcluster/web-server/devel/nginx Job create succeeded: job url=http://192.168.33.7:8081/scheduler/web-server/devel/nginx
Visit the scheduler to see the status of the job. Beware that if you did not pre-pull the image and it takes too long to download, the scheduler will kill the container and try again. Don’t worry - it should come up eventually!
Explore the official DSL documentation and deploy your own containers across Mesos on Aurora!