64
This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes

This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

This job is too hard.

Brendan Burns – @brendandburns

Distinguished Engineer – Microsoft Azure

Co-Founder Kubernetes

Page 2: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

The job.

• Build new features?

• Weekly releases?

• Perfect uptime?

• Remain buzzword compliant?

Page 3: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

The tools.

• Patterns and practices.

• Infrastructure support.

• Code re-use.

• Hacker news.

Page 4: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

The approach.

• Learn everything.

• Build everything.

• Explain everything.

• Monitor everything.

• Rinse and repeat.

Page 5: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

We can’t keep doing this.

Page 6: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Fortunately, history repeats

Page 7: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

What happens when the job gets to hard?

Page 8: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

We build tools.

Page 9: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

We find patterns

Page 10: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Historical reference points

• Machine code - 1940s• Fortran - 1956• The art of computer programming - 1968

Page 11: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Historical reference points

• Software Scaling - 1980s• Java/C# - 1990s• Design Patterns - 1995

Page 12: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Historical reference points

• Reliable Distributed Systems - 2010s• Docker & Kubernetes – 2013-14• ????

Page 13: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Solutions: Tools

• Examples:• Compilers• Debuggers• Unit testing• Integrated Development Environments• ...

Page 14: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Solutions: Tools

• Helm (https://helm.sh)

• Kubernetes Extension for Visual Studio Code

• Draft (https://draft.sh)

• Telepresence (https://telepresence.io)

• Jenkins X (https://github.com/jenkins-x)

• Spinnaker (https://spinnaker.io)

• …

Page 15: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Demo: Visual Studio Code for Kubernetes

Page 16: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Demo: Draft (https://github.com/Azure/draft)

Page 17: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

Cluster Services

• Cluster wide standardization of common services• e.g Logging, Monitoring, Security

• Automatically enabled by deploying into the cluster

• Ensure consistency, concentration of skills & best practices

Page 18: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

I think I’ll use statsd

I think I’ll use prometheus

Monitoring?

Page 19: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

I think I’ll quit.

Page 20: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

Kubernetes API Server

Cluster Wide Monitoring

Create Pods

Page 21: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

Kubernetes API Server

Cluster Wide Monitoring

Get Pods

Page 22: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

Kubernetes API Server

Cluster Wide Monitoring

Monitor Pods

Page 23: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Cluster Services

Kubernetes API Server

Cluster Wide Monitoring

Monitor Pods

Cloud Monitoring

SaaS

Page 24: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Solutions: Patterns & Libraries

• Examples:• Posix• npm install …• Unit testing• Extensible libraries of patterns• ...

Page 25: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Solutions: Patterns and libraries

• Brigade (https://brigade.sh)

• Service Mesh• Istio (https://istio.io)• linkerd (https://buoyant.io)

• Hadoop/Spark/…• PaaS on top of Kubernetes

Page 26: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Brigade (https://brigade.sh)

Event Listener

GithubBuild Script

Page 27: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Brigade (https://brigade.sh)const { events, Job , Group} = require("brigadier");const dest = "$GOPATH/src/github.com/technosophos/ulid";

events.on("push", (e, p) => { var gh = JSON.parse(e.payload) var test = new Job("test", "golang:1.9") test.tasks = [ "mkdir -p " + dest, "cp -a /src/* " + dest, "cd " + dest, "go get -u github.com/golang/dep/cmd/dep", "dep ensure", "make test" ]; test.run() });

Page 28: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Brigade (https://brigade.sh)

BrigadeProgram

Github Event Source

Event Dispatcher

Build Script

Page 29: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Solutions: Language Features

• Examples:• synchronized• async/await• Garbage Collection• Single threading• Channels• ...

Page 30: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

How do we build a language idiomatic cloud?

Page 31: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

The problem(s).

• Code to cloud*

• Cloud* to distributed system

* 'cloud' represents API driven deployment infrastructure

Page 32: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

From code to cloud

@code

Binary

CompilerDockerfile Docker

Image

Container Repo.

KubernetesConfig(s)

Deployed Application

KubernetesCluster

Page 33: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

From code to cloud

• At least three files• Code, Dockerfile, Kubernetes Config

• At least three languages• Code, Dockerfile, YAML

• At least three tools• Editor, docker, kubectl

Page 34: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

And we haven't talked distributed systems...

Page 35: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Or day two operations…

Page 36: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Does this seem ok?

Page 37: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Design Principles

It has to be a formal programming language

Page 38: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Design Principles

It can’t be a PaaS/Walled Garden

Page 39: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Design Principles

It needs to be idiomatic

Page 40: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Design Principles

It has to be open source

Page 41: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

More learning from history

public class MyMapper { … }

public class MyReducer { … }

Page 42: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

More learning from (recent) history

values = [...]

values.map(lambda x … )

Page 43: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

More learning from (recent) history

values = [...]

values.map(lambda x … )

pywren.map(values, lambda x …)

Page 44: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle (https://metaparticle.io)

Page 45: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle (https://metaparticle.io)

I think I’ll build a reliable web app….

Page 46: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle (https://metaparticle.io)

My App

Server

My App

Server

My App

Server

My App

Server

Load Balancer

Public IP Address

Page 47: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle (Python)from metaparticle import containerize

@containerize( options={ 'ports': [8080], 'replicas': 4, })

def main(): Handler = MyHandler httpd = SocketServer.TCPServer(("", port), Handler) httpd.serve_forever()

Page 48: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle

My App

Server

My App

Server

My App

Server

My App

Server

Load Balancer

Public IP Address

MetparticleCompiler

Page 49: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle

My App

Server

My App

Server

My App

Server

My App

Server

Load Balancer

Public IP Address

MetparticleAssembler

MetparticleCompiler

Page 50: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle (Javascript)const mp = require('@metaparticle/package');

const server = http.createServer((request, response) => {response.end(`Hello World: hostname: ${os.hostname()}\n`);

});

mp.containerize({

‘replicas’: 4},() => {

server.listen(port, () => {console.log(`server up on ${port}`);

});}

);

Page 51: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle Languages

• Python

• Javascript

• Java

• C#

• Go

• Rust

• Ruby

• <your favorite language here>

Page 52: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Demo

Page 53: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

more containers, more problems...

Page 54: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Synchronization

import io.metaparticle.sync.Lock;

public class Main { public static void main(String[] args) throws InterruptedException { Lock lock = new Lock("test");

lock.lock(); Thread.sleep(45 * 1000); lock.unlock(); }}

Page 55: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle Synchronization

Pod AppContainer

Locking Sidecar

Pod AppContainer

Locking Sidecar

Kubernetes Custom Lock Resource

Page 56: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Synchronization

import metaparticle_sync

def master_fn(): print('I am the master')

def lost_master_fn(): print('I lost the master')

el = metaparticle_sync.Election('test', master_fn, lost_master_fn)el.run()

Page 57: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Moving on...

Page 58: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Sharding

Page 59: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Sharding@Runtime( shards = 4, urlShardPattern = "^\\/users\\/([^\\/]*)\\/.*")@Package( repository="brendanburns", jarFile="target/metaparticle-package-0.1-SNAPSHOT-jar-with-dependencies.jar")

public static void main(String[] args) { Containerize(() -> { try { HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0); server.createContext("/", new HttpHandler() { . . . }); });}

Page 60: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Metaparticle: Demo

Page 61: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Taking it further: MetaML

Page 62: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

MetaML Example

@Train( package={ 'name': 'some_image_name', 'repository': 'some_docker_repo', 'publish': True}, strategy=HyperparameterTuning({ 'learning_rate': random.normalvariate(0.5, 0.5)}, parallelism=3), tensorboard={ 'log_dir': FLAGS.log_dir, } )

def my_training_function(learning_rate): # some training logic ...

https://aka.ms/metaml

Page 63: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

MetaML Example

from metaml.serve import Serve

@Serve(package={ 'name': 'simple-serve', 'repository': 'wbuchwalter', 'publish': True})

def func(): return "hello world"

func()

Page 64: This job is too hard. - GOTO Conference · This job is too hard. Brendan Burns – @brendandburns Distinguished Engineer – Microsoft Azure Co-Founder Kubernetes. The job. •Build

Where to next?

• https://metaparticle.io

• https://github.com/metaparticle-io/

• https://aka.ms/metaml