Continuous Deployment with Mesosphere

this worked

Ben Whitehead
ben.whitehead@mesosphere.io

Sunil Shah
sunil@mesosphere.io

We are Mesosphere

240 million monthly active users

500 million tweets per day

Up to 150k tweets per second

More than 100TB per day of compressed data

“Mesos is the cornerstone of our elastic compute infrastructure — it's how we build all our new services and is critical for Twitter's continued success at scale. It's one of the primary keys to our data center efficiency.” — Chris Fry, SVP of Engineering at Twitter

Mesoswhat?

Marathon

Chronos

Demo`s!

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 for all the things

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

Mesoswhat?

Marathon

Chronos

Demo!

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
  • 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}

...

Mesoswhat?

Marathon

Chronos

Demo!

Introducing Chronos

a scheduler for batch and one-off jobs

Distribute a graph of jobs

Dependency graph for execution

Features


  • Distributed job scheduler
  • Web interface, API
  • Highly available, no SPoF
  • Native Docker support
  • Easy scheduling with repeating intervals

Chronos REST


PUT chronos-node:8080/scheduler/job/job1
GET chronos-node:8080/scheduler/jobs
DELETE chronos-node:8080/scheduler/task/kill/job2

Mesoswhat?

Marathon

Chronos

Demo!

Continuous Delivery Pipeline

Code Base

Docker Build

Steps

  1. docker login
  2. docker build
  3. docker push
  4. report tag

Artifacts

  1. docker-tag
  2. target/marathon.json

Dockerfile


FROM nginx
MAINTAINER Mesosphere support@mesosphere.io

EXPOSE 80

ADD app/ /usr/share/nginx/html
          

marathon.json


{
  "id": "/mesosphere/cd-demo-app",
  "instances": 1,
  "cpus": 1,
  "mem": 512,
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "mesosphere/cd-demo-app:$tag",
      "network": "BRIDGE",
      "portMappings": [
        { "servicePort": 28080, "containerPort": 80, "hostPort": 0, "protocol": "tcp" },
        { "servicePort": 28443, "containerPort": 443, "hostPort": 0, "protocol": "tcp" }
      ]
    }
  },
  "healthChecks": [
    {
      "gracePeriodSeconds": 120,
      "intervalSeconds": 30,
      "maxConsecutiveFailures": 3,
      "path": "/",
      "portIndex": 0,
      "protocol": "HTTP",
      "timeoutSeconds": 5
    }
  ],
  "constraints": [
    ["hostname", "GROUP_BY"]
  ]
}
          
          

Report Tag


mkdir -p target

echo %TAG% > target/docker-tag

cat marathon.json | \
  jq '.container.docker.image |= "%DOCKER_IMAGE%:%TAG%"' > target/marathon.json
          

Artifacts

Deploy

  1. http PUT http://marathon/v2/apps < marathon.json
  2. Send slack message

Slack Message


echo '{
  "username"   :"%SLACK_USERNAME%",
  "channel"    :"%SLACK_CHANNEL%",
  "text"       :"%SLACK_MESSAGE%",
  "icon_emoji" :"%SLACK_EMOJI%",
  "mrkdwn"     :%SLACK_MARKDOWN%
}' | http --print=HhBb --json POST %SLACK_WEBHOOK_URL%
          

Build Parameters

Roll Out

Marathon will now begin rolling out1 the updated version of the application and your team has just been notified of the deployment.

[1] https://mesosphere.github.io/marathon/docs/deployments.html#rolling-restarts

Demo Slide

Thanks!

Come and talk to us

P.S., we're hiring!

Get Mesosphere packages: mesosphere.io/downloads

Read about Marathon: github.com/mesosphere/marathon

Read about Chronos: github.com/mesos/chronos

Try out Mesosphere on GCE: google.mesosphere.io

Come work with us: mesosphere.io/jobs