Get started with Developing Frameworks in Go on Apache Mesos

50
Get started with Developing Frameworks in Go on Apache Mesos

Transcript of Get started with Developing Frameworks in Go on Apache Mesos

Page 1: Get started with Developing Frameworks in Go on Apache Mesos

Get started with Developing Frameworks in Go on Apache Mesos

Page 2: Get started with Developing Frameworks in Go on Apache Mesos

Joe Stein

CEO, Co-Founder of Elodina Inc, Software Platform focused on simplified operations of data oriented systems by providing the tools and support necessary to fully utilize their data center resources.

LinkedIn: http://linkedin.com/in/charmalloc Twitter : @allthingshadoop

Page 3: Get started with Developing Frameworks in Go on Apache Mesos

◉ What is Mesos?◉ Framework = (Scheduler + Executor)◉ Framework API Examples◉ More Mesos!

Overview

Page 4: Get started with Developing Frameworks in Go on Apache Mesos

What is Mesos?

Page 6: Get started with Developing Frameworks in Go on Apache Mesos
Page 7: Get started with Developing Frameworks in Go on Apache Mesos
Page 8: Get started with Developing Frameworks in Go on Apache Mesos
Page 9: Get started with Developing Frameworks in Go on Apache Mesos
Page 10: Get started with Developing Frameworks in Go on Apache Mesos

static vs elastic

Page 11: Get started with Developing Frameworks in Go on Apache Mesos

Data Center Kernel

Page 12: Get started with Developing Frameworks in Go on Apache Mesos

Data Center Operating System

Mesosphere’s Data Center Operating System (DCOS) is an operating system that spans all of the machines in a datacenter or cloud and treats them as a single computer, providing a highly elastic and highly scalable way of deploying applications, services, and big data infrastructure on shared resources. DCOS is based on Apache Mesos and includes a distributed systems kernel with enterprise-grade security. It also includes a set of core system services, such as a native Marathon instance to manage processes and installable services, and Mesos-DNS for service discovery. DCOS provides a web interface and a command-line interface (CLI) to manage the deployment and scale of applications.

Page 13: Get started with Developing Frameworks in Go on Apache Mesos
Page 14: Get started with Developing Frameworks in Go on Apache Mesos
Page 15: Get started with Developing Frameworks in Go on Apache Mesos
Page 16: Get started with Developing Frameworks in Go on Apache Mesos

Framework = (Scheduler + Executor)

Page 17: Get started with Developing Frameworks in Go on Apache Mesos
Page 18: Get started with Developing Frameworks in Go on Apache Mesos

Scheduler

Page 19: Get started with Developing Frameworks in Go on Apache Mesos

Executors

Page 20: Get started with Developing Frameworks in Go on Apache Mesos

Marathonhttps://github.com/mesosphere/marathonCluster-wide init and control system for services in cgroups or docker based on Apache Mesos

Page 21: Get started with Developing Frameworks in Go on Apache Mesos

Stack Deploy https://github.com/elodina/stack-deploy

Page 22: Get started with Developing Frameworks in Go on Apache Mesos

Use YAML to Configure Your Deploy

Page 23: Get started with Developing Frameworks in Go on Apache Mesos

Framework API & Examples

Page 24: Get started with Developing Frameworks in Go on Apache Mesos

Mesos Protos

https://github.com/apache/mesos/blob/master/include/mesos/mesos.proto

Everything is good to understand but here is a good place to start

◉ FrameworkInfo◉ TaskInfo◉ TaskState◉ MasterInfo◉ SlaveInfo

Page 25: Get started with Developing Frameworks in Go on Apache Mesos

Mesos Framework Development Guide

http://mesos.apache.org/documentation/latest/app-framework-development-guide/

Go Bindings https://github.com/mesos/mesos-go

◉ Scheduler API○ registered, reregistered, disconnected○ resourceOffers, offerRescinded, statusUpdate, frameworkMessage○ slaveLost, executorLost, error

◉ Executor API○ registered, reregistered, disconnected○ launchTask, killTask, frameworkMessage

Page 26: Get started with Developing Frameworks in Go on Apache Mesos

Go Kafka Client Mesos https://github.com/elodina/go-kafka-client-mesos

Page 27: Get started with Developing Frameworks in Go on Apache Mesos

More About the Scheduler

Page 28: Get started with Developing Frameworks in Go on Apache Mesos

Scheduler

Page 29: Get started with Developing Frameworks in Go on Apache Mesos

Scheduler

Page 30: Get started with Developing Frameworks in Go on Apache Mesos

Scheduler

Page 31: Get started with Developing Frameworks in Go on Apache Mesos

Task Reconciliation

http://mesos.apache.org/documentation/latest/reconciliation/

It is the responsibility of Mesos (scheduler driver / Master) to ensure that the framework is notified when a disconnection, and subsequent (re-)registration occurs. At this point, the scheduler should perform task state reconciliation.

Page 32: Get started with Developing Frameworks in Go on Apache Mesos

Executor

Page 33: Get started with Developing Frameworks in Go on Apache Mesos

Executor

Page 34: Get started with Developing Frameworks in Go on Apache Mesos
Page 36: Get started with Developing Frameworks in Go on Apache Mesos

More Mesos!

Page 37: Get started with Developing Frameworks in Go on Apache Mesos

The Mesos system has two basic methods to describe the slaves that comprise a cluster. One of these is managed by the Mesos master, the other is simply passed onwards to the frameworks using the cluster.

AttributesThe attributes are simply key value string pairs that Mesos passes along when it sends offers to frameworks.

Resources & Attributes

Page 38: Get started with Developing Frameworks in Go on Apache Mesos

ResourcesThe Mesos system can manage 3 different types of resources: scalars, ranges, and sets. These are used to represent the

different resources that a Mesos slave has to offer. For example, a scalar resource type could be used to represent the

amount of memory on a slave. Each resource is identified by a key string.

Page 39: Get started with Developing Frameworks in Go on Apache Mesos

Predefined Uses & Conventions

The Mesos master has a few resources that it pre-defines in how it handles them. At the current time, this list consist of:

●●●●

In particular, a slave without and resources will never have its resources advertised to any frameworks. Also, the Master’s

user interface interprets the scalars in and in terms of . IE: the value is displayed as .

Page 40: Get started with Developing Frameworks in Go on Apache Mesos

ExamplesHere are some examples for configuring the Mesos slaves.

In this case, we have three different types of resources, scalars, a range, and a set. They are called , , , and the range type

is .

● scalar called , with the value

● scalar called , with the value

● scalar called , with the value

● range called , with values through (inclusive)

● set called , with the values , and

In the case of attributes, we end up with three attributes:

● with value

● with value

● with value

Page 41: Get started with Developing Frameworks in Go on Apache Mesos

RolesTotal consumable resources per slave, in the form 'name(role):value;name(role):value...'. This value can be set to limit resources per role, or to overstate the number of resources that are available to the slave.

All * roles will be detected, so you can specify only the resources that are not all roles (*).

Page 42: Get started with Developing Frameworks in Go on Apache Mesos

ConstraintsConstraints control where apps run to allow optimizing for fault tolerance or locality. Constraints are made up of three parts: a field

name, an operator, and an optional parameter. The field can be the slave hostname or any Mesos slave attribute.

Fields

Hostname field

field matches the slave hostnames, see for usage example.

field supports all operators of Marathon.

Attribute field

If the field name is none of the above, it will be treated as a Mesos slave attribute. Mesos slave attribute is a way to tag a slave node,

see to learn how to set the attributes.

Page 43: Get started with Developing Frameworks in Go on Apache Mesos

Unique tells Marathon to enforce uniqueness of the attribute across all of an app's tasks. For example the following constraint ensures

that there is only one app task running on each host:

via the Marathon gem:

via curl:

Page 44: Get started with Developing Frameworks in Go on Apache Mesos

allows you to run all of your app's tasks on slaves that share a certain attribute.

You can also use this attribute to tie an application to a specific node by using the hostname property:

Cluster

Page 45: Get started with Developing Frameworks in Go on Apache Mesos

Group By can be used to distribute tasks evenly across racks or datacenters for high availability.

via the Marathon gem:

via curl:

Optionally, you can specify a minimum number of groups to try and achieve.

Page 46: Get started with Developing Frameworks in Go on Apache Mesos

Like accepts a regular expression as parameter, and allows you to run your tasks only on the slaves whose field values match the

regular expression.

via the Marathon gem:

via curl:

Page 47: Get started with Developing Frameworks in Go on Apache Mesos

UnlikeJust like operator, but only run tasks on slaves whose field values don't match the regular expression.

via the Marathon gem:

via curl:

Page 48: Get started with Developing Frameworks in Go on Apache Mesos

Go Mesos Constraints & More!

https://github.com/elodina/go-mesos-utils

--constraints: Constraints (hostname=like:^master$,rack=like:^1.*$).

Page 49: Get started with Developing Frameworks in Go on Apache Mesos
Page 50: Get started with Developing Frameworks in Go on Apache Mesos

Questions?

Joe Steinhttp://www.elodina.net