Docker container using Apache Mesos and Marathon

apache-mesos-logo apache-mesos-marathon-logo Docker Logo

Apache Mesos is an open source cluster manager developed at UC Berkeley. It provides resource isolation and sharing across distributed applications.

The figure shows the main components of Mesos. Mesos consists of a master daemon that manages slave daemons running on each cluster node. Mesos frameworks are applications that run on Mesos and run tasks on these slaves. Slaves are either physical or virtual machines, typically from the same provider.

mesos-architecture

Mesos uses a two-level scheduling mechanism where resource offers are made to frameworks. The Mesos master node decides how many resources to offer each framework, while each framework determines the resources it accepts and what application to execute on those resources.

Marathon is a container orchestration platform running on Mesos. Multiple container formats are supported and Docker is certainly the most common one!

This blog will show how to setup Mesos, Marathon, and run a simple Docker image. This setup is only for the brave of heart. I’m always interested in looking under the hood and that’s what motivated this post. But a future post will show a more seamless install.

Let’s get started!

Configure CentOS VM

Download CentOS and configure the VM as shown:

centos-7.1-install

Install Components

Install the different components required for this setup.

  1. Configure Mesos repo:
  2. Install Mesos and Marathon:
  3. Install ZooKeeper:
  4. Add Docker repo:
  5. Install Docker:

Configure Hostname/IP address Mapping

Edit /etc/hosts and create hostname and IP address mapping. Find IP address using ifconfig and choose the network interface enabled during CentOS installation.

Start Services

Start all the services

  1. Start Docker:
  2. Start ZooKeeper:
  3. Start Mesos master:
  4. Configure mesos and docker containerizers:
  5. Start Mesos slave:
  6. Start Marathon:
  7. Check for services:Mesos UI: http://127.0.0.1:5050
    Marathon UI: http://127.0.0.1:8080
    Logs: tail -f /var/log/messages
  8. Check Mesos master:
  9. Check Mesos slave:
  10. Check ZooKeeper:

Deploy Docker application to Mesos

A simple Docker-based application is defined using the configuration file. Marathon runs on port 8080 and so the updated configuration file looks like:

Deploy the application as:

The application will take some time in order to download the image and then run the container. This setup is slightly sensitive and multiple runs of the application showed that the Docker image was not successfully downloaded all the times. In that case, the Docker image was manually downloaded using docker pull python:3 and then the application could be successfully deployed.

In our case, master and slave are running on the same machine, and so the list of Docker images and running containers can be easily seen:

The application is available at port 31669 and can be seen at http://127.0.0.1:31669 as:

mesos-marathon-app-output

Mesos UI (http://127.0.0.1:5050) shows:
marathon-ui-app-output

Marathon UI (http://127.0.0.1:8080) shows:
mesos-ui-app-output

As you can see, this is quite an involving setup. A future blog post will show how to use DC/OS and set this up more seamlessly.

Further reading …

  • Mesos Marathon
  • Ports in Mesos
  • Mesos CLI
  • Mesos – Under the Hood

Mesos slack channel is awesome! Particularly I learned a lot about Mesos from @jgarcia.mesosphere, @akaplan.mesosphere, @harpreet.mesosphere, @graham.mesosphere. Thanks guys, keep up on engaging with the community!

Enjoy!

Source: http://blog.couchbase.com/2016/may/docker-apache-mesos-marathon

Be Sociable, Share!
  • Tweet

Leave a Reply

Your email address will not be published. Required fields are marked *