Using Puppet with Mesos
Mesos is an open source software application that lets you treat your data center like a single pool of resources. Mesos abstracts CPU, memory, storage, and other compute resources away from the underlying machines, enabling you to build and run fault-tolerant and elastic systems more easily.
A good example of where Mesos has been used is at Apple, with Mesos providing the supporting platform for the Siri voice service.
Mesos is typically used to provide a higher-level interface to a large cluster of computers, to help move away from a host-centric view of compute resources towards a more application-centric view. That doesn’t mean those underlying hosts don’t exist or don’t need management, but that the abstraction makes it easier to maintain consistency and to provide a common platform for running applications. This is why Mesosphere, a company developing and supporting customers who use Mesos, calls it a “data center operating system” (DCOS).
Installing Mesos with Puppet
The first thing you’ll likely want to do is to get Mesos installed on a cluster of machines. There are a number of Puppet modules on the Forge to help with that, including deric/mesos and pennycoders/mesos. With the deric/mesos module, which has been downloaded more than 14,000 times, setting up a Mesos master is as simple as this:
Once you have a Mesos master running, you’ll likely want to launch several slaves, too. You can install Mesos and configure the slave with something like this:
The module has lots of parameters for changing the configuration of the Mesos services, as well as additional types for things like installing Mesos CLI tools and managing Mesos package repositories. The documentation covers these in lots of detail for those just getting started.
Installing Mesos frameworks with Puppet
Mesos itself deals with the low-level aspects of the distributed system, and provides a well-structured API for more user-facing frameworks. Some of the most popular Mesos frameworks are Chronos, Marathon and Aurora, and as luck would have it, there are modules for managing all of those with Puppet.
Chronos is a distributed and fault-tolerant job scheduler, in effect a replacement for cron. If you’ve managed individual cron jobs, you’ll be familiar with this problem: What if the underlying host is down when the job is meant to run? What if you want a job to run only once across all your machines, rather than once per machine? Chronos solves those types of problems by describing jobs at the cluster level rather than at the host level. Puppet Labs itself uses Chronos internally, and our operations team created the puppetlabs/chronos module which supports installing Chronos using Puppet, as well as some of other features we’ll look at later in this post.
Marathon is described as a cluster-wide init and control system for services in cgroups or Docker containers, running on top of Mesos. If Chronos is a cluster-aware replacement for cron, then Marathon can be thought of as a cluster-aware replacement for the system init mechanism.
Whereas Chronos would tend to be used for periodic and batch jobs, Marathon is better suited to persistent processes — for instance, application servers. The advantage of doing this on Mesos is that the scheduling can be automatically done based on the availability of relevant resources, so you'll be running services on under-utilized hardware, or only where the right mix of operating system, storage and network are available. There are a number of modules on the Forge for Marathon, all with a similar number of downloads: pennycoders/marathon, praekeltfoundation/marathon and potto/marathon. Do take a look at all of them and provide feedback to the authors — it would be great to see one of them make it onto the Puppet Approved list.
Here’s an example of using the praekeltfoundation/marathon module:
Last but not least is the Apache Aurora framework. Aurora is an alternative to Chronos and Marathon that provides some interesting features around its own scheduling domain specific language, as well as rolling updates and rollback for application changes. The jfarrell/aurora module provides support in Puppet for installing and managing Aurora.
Using Mesos with Puppet
As well as simply installing and managing Mesos and its accompanying frameworks, Puppet can also be used to drive the usage of Mesos. For example, today you might describe your cron jobs with Puppet code, something like the following:
As mentioned above, Chronos is a distributed replacement for Cron running on top of Mesos. So it makes perfect sense to therefore manage the new job in Puppet too. The puppetlabs/chronos module supports just that use case with the
The above modules all provide the base for you to install and manage Mesos with Puppet. But it’s often useful to have examples of usage, too. Roger Ignazio, now a software engineer at Mesosphere, wrote this excellent article on managing Mesos with Puppet which covers the steps for getting up and running using some of the content above. The blog post also inspired his talk at PuppetConf for which the slides are also available. For those who want to jump straight in, the above post inspired me to create a Vagrant based example of Puppet managing Mesos for people to experiment with on a local virtual machine.
This collection of modules for managing Mesos with Puppet is another great example of the ingenuity of the Puppet community. Thank you to everyone who has contributed to these modules and to making Puppet a useful tool for managing Mesos. All of this is also a good example of how Puppet is often used to help people adopt newer technologies, bringing a consistency and confidence to how new software is installed, configured and managed. If you have other examples of great Puppet and Mesos integrations, or if you’re happily using both together, please do let us know in the comments.
Gareth Rushgrove is a senior software engineer at Puppet Labs.
We have written a number of recent posts on using different technologies with Puppet. Here are some more to check out: