Deploying Docker Containers at Scale with Mesos and Marathon

Sunil Shah
sunil@mesosphere.io

We are Mesosphere

http://mobro.co/geekonabicycle

An introduction to the world of Mesosphere

Deploying applications with Marathon

Mesosphere on Google Cloud Platform

Status quo is static partitioning
and use of virtual machines

Add some virtual machines

Provision Hadoop

Provision a web service

Moar data, moar Hadoop

Mesos let us treat a cluster of nodes...

As one big computer

Not as individual machines

Not as VMs

But as computational resources like cores, memory, disks, etc.

Mesos is...

Open Source Apache project

Cluster Resource Manager

Scalable to 10,000s of nodes

Fault-tolerant, battle-tested

An SDK for distributed apps

The Mesos ecosystem is
growing

High Level View of Mesos



Framework = scheduler + executor



Schedulers get resource offers

Executors run tasks

We love containers

Most modern applications are a web of containers

Now what?

An introduction to the world of Mesosphere

Deploying applications with Marathon

Mesosphere on Google Cloud Platform

Say hi to Marathon

a self-serve interface to your cluster

distributed "init" for long-running services

a private fault-tolerant PaaS

a container orchestration platform

Marathon does it!


  • Start, stop, scale, update apps
  • Nice web interface, API
  • Highly available, no SPoF
  • Native Docker support (as of Mesos 0.20.0)
  • Pluggable event bus
  • Rolling deploy / restart
  • Application health checks
  • Artifact staging

Service Discovery


Set environment variables

Read config from device (rsync'ed to fs)

Read from K-V store

Use DNS

HAProxy works pretty well

Marathon REST


POST /v2/apps

GET /v2/apps

PUT /v2/apps/{appId}

GET /v2/apps/{appId}/tasks

DELETE /v2/apps/{appId}/tasks/{taskId}

...

An introduction to the world of Mesosphere

Deploying applications with Marathon

Mesosphere on Google Cloud Platform

Run a Docker container

http -v POST http://10.94.29.195:8080/v2/apps @app-ruby.json

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "rails server -p $PORT",
  "id": "rails-demo",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000]
}

          

Scale!

http -v PUT http://10.94.29.195:8080/v2/apps/demo @scale-app.json

{
  "instances": 3
}

          

Deploy a new Python version

http -v PUT http://10.94.29.195:8080/v2/apps/demo @app-python.json

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd":  "python -m SimpleHTTPServer $PORT",
  "id": "demo",
  "instances": 3,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000]
}
          

Use HTTP healthchecks

http -v POST http://10.94.29.195:8080/v2/apps @app-with-healthcheck.json

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "rails server -p $PORT",
  "id": "healthcheck-demo",
  "instances": 1,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000],
  "healthChecks": [
    {
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "gracePeriodSeconds": 30,
      "intervalSeconds": 30,
      "timeoutSeconds": 30,
      "maxConsecutiveFailures": 0
    }
  ],
  "constraints": [
      ["hostname", "UNIQUE"]
  ]
}
          

Add a UNIQUE hostname constraint

http -v POST http://10.53.20.188:8080/v2/apps @app-with-constraint.json

{
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "superguenter/demo-app"
    }
  },
  "cmd": "python -m SimpleHTTPServer $PORT",
  "id": "constraint-demo",
  "instances": 6,
  "cpus": 0.01,
  "mem": 256,
  "ports": [3000],
  "healthChecks": [
    {
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP"
    }
  ],
  "constraints": [
      ["hostname", "UNIQUE"]
  ]
}
          

Mesos for all the containers

Mesos for all the things

Thanks!

Come and talk to us

Get Mesosphere packages: http://mesosphere.io/downloads

Kubernetes on Mesos: https://github.com/mesosphere/kubernetes-mesos

Read about Marathon: https://github.com/mesosphere/marathon

Try out Mesosphere on GCE: http://google.mesosphere.io