Deploying services with Mesos, Marathon, Zookeeper and Docker

In this post I'll demonstrate how to run a scalable and highly available service inside of Docker containers, managed by Marathon, Mesos and Zookeeper.

Here's a quick overview of the different components involved:

- Apache Zookeeper acts as the master election service, state store and high-performance coordination service for distributed applications such as Mesos. [1]

- Apache Mesos abstracts CPU, memory, storage, and other compute resources in a similar way to Open Stack Compute, effectively acting as a cluster manager and intelligent task distributor across a cluster of machines. The development community describes it as the kernel for distributed systems.[2]

- Marathon is a container orchestration platform and is one of the supported frameworks for Apache Mesos. It acts as a process and service manager. The development community describes it as systemd/upstart for the Mesos kernel.[3]

In a previous post I showed how to deploy Apache Zookeeper from source, but in this tutorial I'll do it from a package.
The setup will consist of 3 nodes running the Zookeeper cluster, and 2 nodes in a master/slave setup running Mesos and Marathon.

First let's install and configure the zookeeper service on the 3 nodes:
Make sure that /var/zookeeper/data/myid has a unique id on each of the 3 servers.

To test if zookeeper is working properly lets insert and retreive a key/value (this is somewhat similar to etcd): Installing Apache Mesos on the master and slave nodes is next: By pointing both Mesos master and slave to the Zookeeper nodes, we delegate election to the Zookeeper service in case the Mesos master fails.
You should be able to access the Mesos GUI on port 5050:

To schedule a test task run:
For full list of the configuration parameters for Mesos refer to [4].

With Mesos deployed installing Marathon is next: Marathon uses --master to find the Mesos masters, and --zk to find ZooKeepers for storing state. The Marathon GUI is now accessible on port 8080.
For full list of the configuration parameters for Marathon refer to [5].

To run an application on Marathon you can either schedule it using the GUI on port 8080, or the REST API:
To list and delete the application through the API:
For a full list of available json config fields refer to [6].

And finally to run a web app from a Docker container:

No comments:

Post a Comment