sunil shah

59
© 2015 Mesosphere, Inc. All Rights Reserved. 1 AGILE DEVELOPMENT AND PAAS USING THE MESOSPHERE DCOS Sunil Shah

Upload: phungdat

Post on 13-Feb-2017

241 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 1

AGILE DEVELOPMENT AND PAAS USING THE MESOSPHERE DCOS

Sunil Shah

Page 2: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 2

THE DATACENTER OPERATING SYSTEM (DCOS)

Page 3: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 3

INTRODUCTIONDCOS

The Mesosphere Datacenter Operating System (DCOS) is a distributed operating system that spans all of the machines in your datacenter or cloud.

It provides a highly elastic, and highly scalable way of deploying applications, services and big data infrastructure on shared resources.

Existing Infrastructure

Mesosphere DCOS

Services & Containers

Page 4: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 4

KEY COMPONENTS

DCOSThe DCOS is built around some key components:

Apache Mesos● Datacenter kernel

Marathon● Datacenter init.d

Docker● Executable format

Universe● DCOS package repository

DCOS CLI● Command line to your datacenter

All of these components are open source!

Page 5: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

DCOS

5

Problem PaaSTA DCOS

Code containerizer Docker Docker

Scheduling Mesos + Marathon Mesos + Marathon

Service Discovery SmartStack Mesos DNS, Marathon-lb

Monitoring Sensu DCOS

Workflow Jenkins or CLI + soa-configs Jenkins, DCOS CLI

DCOS AND PAASTA

Page 6: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 6MODERN INFRASTRUCTURE

Page 7: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 7

CLEAN SEPARATION

MODERN INFRASTRUCTURE

Before

- Dan cares about his hardware and Alice’s software that runs on it

- Alice cares about her software and what hardware Dan provides

Now

- With DCOS, all the nodes are provisioned exactly the same (but may have heterogenous hardware).

- Dan doesn’t care what software is deployed since applications are well encapsulated.

- Alice doesn’t care where her software is deployed because it’s easy enough to scale up and down.

Page 8: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 8

NO MORE 3AM WAKE UPS

MODERN INFRASTRUCTURE

Before

- Dan had to react every time an application or machine went down.

Now

- Mesos and Marathon monitor running tasks.

- If a task fails or is lost (due to a machine going offline), Mesos communicates that to Marathon.

- Marathon restarts the application.

- Dan gets to sleep peacefully!

Page 9: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 9

EASY PROGRAMMATIC DEPLOYMENT

MODERN INFRASTRUCTURE

Before

- Servers were handcrafted.

- Deploying new or updated software would require oversight and involvement from both Alice and Dan.

Now

- Dan provides Alice with her own instance of Marathon that makes it hard for her to take down someone else’s application.

- Running applications are isolated from each other by Mesos.

- Marathon offers a nice API that allows Alice to easily deploy new versions safely.

Page 10: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 10

APACHE MESOS

Page 11: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 11

THE BIRTH OF MESOS

TWITTER TECH TALK

The grad students working on Mesos give a tech talk at Twitter.

March 2010

APACHE INCUBATION

Mesos enters the Apache Incubator.

Spring 2009

CS262B

Ben Hindman, Andy Konwinski and Matei Zaharia create “Nexus” as their

CS262B class project.

MESOS PUBLISHED

Mesos: A Platform for Fine-Grained Resource Sharing in the Data Center is

published as a technical report.

September 2010

December 2010

Page 12: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 12

Apache Mesos

INTRODUCTION

Apache Mesos is a cluster resource manager.

It handles:

● Aggregating resources and offering them to schedulers● Launching tasks (i.e. processes) on those resources● Communicating the state of those tasks back to schedulers● Tasks can be:

● Long running services● Ephemeral / batch jobs

INTRODUCTIONAPACHE MESOS

Page 13: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 13

ARCHITECTUREMESOS FUNDAMENTALS

Page 14: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 14

ARCHITECTUREMESOS FUNDAMENTALS

● Agents advertise resources to Master● Master offers resources to Scheduler● Scheduler rejects/uses resources● Agents report task status to Master

Page 15: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 15

ARCHITECTUREMESOS FUNDAMENTALS

● Agents advertise resources to Master● Master offers resources to Scheduler● Scheduler rejects/uses resources● Agents report task status to Master

Page 16: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 16

ARCHITECTUREMESOS FUNDAMENTALS

● Agents advertise resources to Master● Master offers resources to Scheduler● Scheduler rejects/uses resources● Agents report task status to Master

Page 17: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 17

ARCHITECTUREMESOS FUNDAMENTALS

● Agents advertise resources to Master● Master offers resources to Scheduler● Scheduler rejects/uses resources● Agents report task status to Master

Page 18: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 18

ARCHITECTUREMESOS FUNDAMENTALS

● Agents advertise resources to Master● Master offers resources to Scheduler● Scheduler rejects/uses resources● Agents report task status to Master

Page 19: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 19

MESOS AND MARATHON EXAMPLE

Page 20: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 20

Page 21: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 21

Page 22: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 22

Page 23: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 23

Page 24: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 24

Page 25: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 25

Page 26: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 26

Page 27: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 27

MESOS AND MARATHON EXAMPLE

TASK FAILURE

Page 28: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 28

Page 29: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 29

Page 30: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 30

Page 31: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 31

Page 32: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 32

DEPLOYING A PAAS USING DCOS

Page 33: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 33

DCOS CLI AND THE UNIVERSE

DEPLOYING A PAAS USING DCOS

Page 34: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 34

1. Create a JSON file:{"marathon": {"framework-name": "my-marathon" }}

2. Use the CLI to install it:$ dcos package install --options=my-marathon-config.json marathon

3. ????4. Profit!

MARATHONDEPLOYING A PAAS USING DCOS

Page 35: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 35

MARATHONDEPLOYING A PAAS USING DCOS

Page 36: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 36

1. Add the Multiverse:$ dcos config prepend package.sources https://github.com/mesosphere/multiverse/archive/version-1.x.zip

$ dcos package update

2. Use the CLI to install etcd:$ dcos package install etcd

3. Create a JSON file to configure Kubernetes:{ "kubernetes": { "etcd-mesos-framework-name": "etcd" } }

4. Use the CLI to install Kubernetes:

$ dcos package install --options=my-kubernetes-config.json kubernetes

5. ????6. Profit!

KUBERNETESDEPLOYING A PAAS USING DCOS

Page 37: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 37

KUBERNETESDEPLOYING A PAAS USING DCOS

Page 38: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 38

CONTINUOUS DELIVERY ON DCOS

Page 39: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 39

CONTINUOUS DELIVERY PIPELINECD ON DCOS

Page 40: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 40

1. Configuration2. Build3. Deploy4. Service Discovery5. Monitor

Page 41: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 41

Building a CD pipeline requires configuration in a couple of places:

1. Docker and Marathon files in your repo

2. Build configuration in Jenkins**in the future, you’ll be able to check in your build configuration alongside your repository too!

1. CONFIGURATIONCD ON DCOS

Page 42: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

DEPENDENCY MANAGEMENT

Private Copy

Shared

User Code

Libraries

Virtual Processor

Operating System

Physical Processor

Virtual Machines Containers

User Code

Libraries

Virtual Processor

Operating System

Physical Processor

Start time 30-45 seconds < 50 ms

Stop time 5-10 seconds < 50 ms

Workload density 10 - 100x1x

42

1. CONFIGURATION

Page 43: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 43

DEPENDENCY MANAGEMENT Docker is becoming the de-facto container format for

packaging applications:

● Encapsulates dependencies● Runs on your laptop● Runs on your cluster

Mesos and Marathon have native support for Docker.

Just stick a Dockerfile (or two) in the root of your repository!

1. CONFIGURATION

Page 44: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 44

DEPENDENCY MANAGEMENT

FROM orchardup/python:2.7RUN pip install Flask uwsgi requestsADD . /codeWORKDIR /codeCMD uwsgi --http 0.0.0.0:8080 --wsgi-file whereisbot/whereisbot.py --callable app --master --no-default-app

1. CONFIGURATION

Page 45: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

Marathon application definitions are JSON files that describe:

● resources required● how many instances to run● what command to run● how to check your application is healthy

marathon.json should live in the root of your project repository.

45

APPLICATION CONFIGURATION

1. CONFIGURATION

Page 46: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

{ "id": "/ssk2/whereisbot",

"cmd": "uwsgi --http 0.0.0.0:8080 --wsgi-file whereisbot/whereisbot.py --callable app --master --no-default-app",

"cpus": 0.5,

"mem": 64,

"instances": 1,

"acceptedResourceRoles": [

"slave_public"

],

"container": {

"type": "DOCKER",

"docker": {

"image": "ssk2/whereisbot:<build_tag>",

"network": "BRIDGE",

"portMappings": [

{

"containerPort": 8080,

"hostPort": 0

}]}}, 46

APPLICATION CONFIGURATION

1. CONFIGURATION

Page 47: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

"healthChecks": [

{

"protocol": "HTTP",

"portIndex": 0,

"path": "/",

"gracePeriodSeconds": 5,

"intervalSeconds": 20,

"maxConsecutiveFailures": 3

}

],

"env": {

"VIRTUAL_HOST": "whereis.mesosphere.com",

"SOURCE_JSON": "https://path/to/dates.json"

}

}

47

APPLICATION CONFIGURATION

1. CONFIGURATION

Page 48: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

CD ON DCOS

2. BUILDING

48

It’s trivial to install Jenkins on DCOS:

1. Create a JSON file:{"jenkins": {"framework-name": "my-jenkins" }}

2. Install:

$ dcos package install --options=my-jenkins-config.json jenkins:

3. ???4. Profit!

Page 49: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

CD ON DCOS

2. BUILDING

49

Now, set up your build:

1. Set up a GitHub webhook to trigger Jenkins builds

2. Set up build to run tests

3. Set up triggered build to build and push Docker image

docker build . -t ssk2/whereisbot:$(GIT_BRANCH)

docker push ssk2/whereisbot:$(GIT_BRANCH)

4. Set up triggered build to update marathon.json using jq and PUT to Marathon

http PUT https://dcos/service/my-marathon/v2/app/ssk2/whereisbot < marathon.json

Page 50: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 50

When you PUT to Marathon’s API, you trigger a deployment.

http PUT https://dcos/service/my-marathon/v2/app/ssk2/whereisbot < marathon.json

Marathon attempts to scale application to desired state by:

● Launching new instances● By default try to launch 100% of instances requested at once

● Killing old instances when new instances are healthy

3. DEPLOYINGCD ON DCOS

Page 51: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 51

Two main service discovery mechanisms are provided with DCOS:

1. DNS based (Mesos-DNS)2. HAProxy based (Marathon-lb)

4. SERVICE DISCOVERYCD ON DCOS

Page 52: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 52

MESOS-DNS4. SERVICE DISCOVERY

● Ingests cluster state periodically.

● Uses cluster state to generate DNS records for all running Mesos tasks.

● Services query DNS server to discover IP address and port of other services.

● Primarily used for internal service discovery.

● No extra configuration required!

Page 53: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 53

MARATHON-LB4. SERVICE DISCOVERY

● Ingests state of running Marathon applications.

● Regenerates HAProxy configuration.

● Supports virtual hosts!

● Can be used for both internal and external service discovery.

● Must add HAPROXY_GROUP and HAPROXY_0_VHOST variables to your marathon.json.

Page 54: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 54

5. MONITORINGCD ON DCOS

Marathon takes care of monitoring your application using the health checks you specified earlier!

Page 55: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved. 55

COMING SOON

Page 56: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

LOCAL UNIVERSE

56

COMING SOON

The Universe is the public package repository for DCOS.

It lives on GitHub, assets are stored on DockerHub or Amazon S3.

Often, you don’t want your application to call out to the world.

Alternatively you only want to publish packages locally.

Page 57: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

LOCAL UNIVERSE

57

COMING SOON

Command line features to bundle your own packages and push them up to an internally hosted registries and file servers.

Easily build this into your own pipeline and use the same commands to install your own packages as you do for public packages!

Still very much being built!

Page 58: Sunil Shah

© 2015 Mesosphere, Inc. All Rights Reserved.

PERSISTENT VOLUMES

58

COMING SOON

As of 0.23.0 Mesos now offers primitives to allow schedulers to create volumes.

Marathon will soon have support for these - your application will be able to re-attach to its data!

SchedulerMaster

ACCEPT

CREATE:disk(mysql): 600 persist id = A

OFFER

disk(mysql): 200disk(mysql): 600 persist id = A

OFFER

disk(mysql): 800

role = mysql

Page 59: Sunil Shah

THANK YOU!

59

Come and talk to us!● Email me at [email protected]● Slides will be up at http://mesosphere.github.io/presentations