living the nomadic life - nic jackson

58
www.hashicorp.com O @hashicor p ! [email protected] m

Upload: paris-container-day

Post on 24-Jan-2018

627 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Living the Nomadic life - Nic Jackson

www.hashicorp.comO @hashicorp�

[email protected]

Page 2: Living the Nomadic life - Nic Jackson

[email protected]@sheriffjackson

NIC JACKSON

Page 3: Living the Nomadic life - Nic Jackson

3

AGENDA

HASHICORP

SCHEDULING

NOMAD

Overview Fundamentals

Job ConfigurationSchedulingDemo

Page 4: Living the Nomadic life - Nic Jackson

HASHICORPOVERVIEW

Page 5: Living the Nomadic life - Nic Jackson

5

FOUNDED 2012 by Mitchell Hashimoto and Armon Dadgar

MISSION We enable organizations to provision, secure, and run any infrastructure for any application

INVESTORS Mayfield Fund, GGV Capital, Redpoint and True Ventures

KEY PRODUCTS Vagrant, Packer, Terraform, Vault, Nomad, Consul

COMPANY OVERVIEW

Page 6: Living the Nomadic life - Nic Jackson

6

OSS TO ENTERPRISE

SOFTWARE INNOVATORS TECHNOLOGY PARTNERS

Page 7: Living the Nomadic life - Nic Jackson

7

PRODUCT SUITE

Page 8: Living the Nomadic life - Nic Jackson

8

NOMAD

Nomad

Page 9: Living the Nomadic life - Nic Jackson

SCHEDULINGOVERVIEW

Page 10: Living the Nomadic life - Nic Jackson

Schedulers map a set of work to a set of resources

Page 11: Living the Nomadic life - Nic Jackson

11

CPU SCHEDULER

11

CORE

CORE

CORE

CORE

CPUSCHEDULER

KERNEL

APACHE

REDIS

BASH

Page 12: Living the Nomadic life - Nic Jackson

12

CPU SCHEDULER

12

CORE

CORECPUSCHEDULER

KERNEL

APACHE

REDIS

BASH

Page 13: Living the Nomadic life - Nic Jackson

13

SCHEDULERS IN THE WILD

13

Type Work Resources

CPU Scheduler Threads Physical Cores

EC2 / Nova Virtual Machines Hypervisors

Hadoop YARN MapReduce Jobs Client Nodes

Cluster Scheduler Applications Machines

Page 14: Living the Nomadic life - Nic Jackson

14

SCHEDULER ADVANTAGES

14

Higher Resource Utilization

Decouple Work from Resources

Better Quality of Service

Page 15: Living the Nomadic life - Nic Jackson

15

SCHEDULER ADVANTAGES

15

Bin Packing

Over-Subscription

Job Queueing

Higher Resource Utilization

Decouple Work from Resources

Better Quality of Service

Page 16: Living the Nomadic life - Nic Jackson

16

SCHEDULER ADVANTAGES

16

Abstraction

API Contracts

Standardization

Higher Resource Utilization

Decouple Work from Resources

Better Quality of Service

Page 17: Living the Nomadic life - Nic Jackson

17

SCHEDULER ADVANTAGES

17

Priorities

Resource Isolation

Pre-emption

Higher Resource Utilization

Decouple Work from Resources

Better Quality of Service

Page 18: Living the Nomadic life - Nic Jackson

18

NOT A NEW CONCEPT

18

Page 19: Living the Nomadic life - Nic Jackson

19

BASED ON RESEARCH

19

Page 20: Living the Nomadic life - Nic Jackson

NOMADOVERVIEW

Page 21: Living the Nomadic life - Nic Jackson

21

NOMAD DESIGN PRINCIPLES

21HashiCorp confidential do not distribute

Integrated scheduler and cluster manager

Distributed, shared state, optimistically concurrent

Agent-based, client/server

No dependencies

Page 22: Living the Nomadic life - Nic Jackson

22

NOMAD CHARACTERISTICS

22HashiCorp confidential do not distribute

Multi-datacenter and multi-region

Highly performant and highly available

Hybrid workloads with multiple schedulers and drivers

Seamlessly integrates with HashiCorp ecosystem

Page 23: Living the Nomadic life - Nic Jackson

NOMADFUNDAMENTALS

Page 24: Living the Nomadic life - Nic Jackson

24

SINGLE REGION DEPLOYMENT

24

SERVER SERVER SERVER

CLIENT CLIENT CLIENTDC1 DC2 DC3

FOLLOWER LEADER FOLLOWER

REPLICATIONFORWARDING

REPLICATIONFORWARDING

RPC RPC RPC

Page 25: Living the Nomadic life - Nic Jackson

25

MULTI REGION DEPLOYMENT

25

SERVER SERVER SERVERFOLLOWER LEADER FOLLOWER

REPLICATIONFORWARDING

REPLICATION

REGION B� GOSSIP

REPLICATION REPLICATIONFORWARDING

REGION FORWARDING

�REGION A

SERVERFOLLOWER

SERVER SERVERLEADER FOLLOWER

Page 26: Living the Nomadic life - Nic Jackson

26

SERVER ARCHITECTURE

26

Omega Class Scheduler

Pluggable Logic

Internal Coordination and State

Multi-Region / Multi-Datacenter

Page 27: Living the Nomadic life - Nic Jackson

27

CLIENT ARCHITECTURE

27

Broad OS Support

Host Fingerprinting

Pluggable Drivers

Job restarts and lifecycle management

Page 28: Living the Nomadic life - Nic Jackson

28

CLIENT DRIVERS

28

ContainerizedDockerrktWindows Server Containers

VirtualizedQemu / KVM

Hyper-VXen

StandaloneJava Jar

C#Static Binaries

Page 29: Living the Nomadic life - Nic Jackson

29

CLIENT FINGERPRINTING

29

Type Examples

Operating System Kernel, OS, Version

Hardware CPU, Memory, Disk

Apps (Capabilities) Docker, Java, Consul

Environment AWS, GCE

Page 30: Living the Nomadic life - Nic Jackson

NOMADJOB CONFIGURATION

Page 31: Living the Nomadic life - Nic Jackson

31

JOB FILE

31

Declarative

Scheduler, driver, and resource needs

Lifecycle behavior

Constraints

Versioned

Page 32: Living the Nomadic life - Nic Jackson

32

redis.nomad

JOB FILE

job "redis" { datacenters = ["us-east-1"]

task "redis" {

driver = "docker" config { image = "redis:v13" }

resources { cpu = 500 # Mhz memory = 256 # MB

network { mbits = 10 dynamic_ports = ["redis"] } } }}

Page 33: Living the Nomadic life - Nic Jackson

33

redis.nomad

JOB FILE: TASK GROUPS

job "app" {

group "app" {

task "redis" {# ...

}

task "app" {# ...

}

}

}

Page 34: Living the Nomadic life - Nic Jackson

34

redis.nomad

JOB FILE: CONSTRAINTS

job "redis" {

constraint { attribute = "${attr.kernel.version}" operator = "version" value = "> 3.19"}

constraint { attribute = "${attr.platform.aws.instance-type}"

value = "p2.16xlarge"}

task "redis" {# ...

}

}

Page 35: Living the Nomadic life - Nic Jackson

35

redis.nomad

JOB FILE: CONSUL SERVICE DISCOVERY

job "redis" {

task "redis" {# ...

service {port = “redis”check {

type = “tcp”interval = “10s”

} }

}

}

Page 36: Living the Nomadic life - Nic Jackson

36

redis.nomad

JOB FILE: CONSUL CONFIGURATION

job "redis" {

task "redis" {# ...

template {data = <<EOH

bind_port: {{ env "NOMAD_PORT_db" }}scratch_dir: {{ env "NOMAD_TASK_DIR" }}service_key: {{ key "service/my-key" }}

EOH

destination = "local/file.yml"}

}

}

Page 37: Living the Nomadic life - Nic Jackson

37

redis.nomad

JOB FILE: VAULT INTEGRATION

job "redis" {

task "redis" {# ...

template { data = <<EOH

{{ with secret "secret/credentials" }} username: {{ .Data.username }} password: {{ .Data.password }}{{ end }}

EOH

destination = "local/file.yml"}

}

}

Page 38: Living the Nomadic life - Nic Jackson

38

redis.nomad

JOB FILE: PARAMETERIZED

job "encode" {

type = "batch"

parameterized {payload = "required"meta_required = ["s3-input", "s3-output", ...]

} # ...

task "ffmpeg" {driver = "exec"

config {command = "ffmpeg"

# When dispatched, the payload is written to a file that is then# read by the created task upon startupargs = ["-config=${NOMAD_TASK_DIR}/config.json"]

# ...}

Page 39: Living the Nomadic life - Nic Jackson

39

$ nomad job dispatch encode video-config.json$$ cat video-config.json

{ "s3-input": "https://s3-us-west-1.com/video-bucket/cb31dabb1", "s3-output": "https://s3-us-west-1.com/video-bucket/a149adbe3", "input-codec": "mp4", "output-codec": "webm", "quality": "1080p"}

Text

JOB FILE: PARAMETERIZED

Page 40: Living the Nomadic life - Nic Jackson

NOMADMULTI-CLOUD

Page 41: Living the Nomadic life - Nic Jackson

Why Multi-Cloud?

• High Availability

• Redundancy

• Burstable Workload

• Cloud Migration

• Because we can

Page 42: Living the Nomadic life - Nic Jackson

42

CONSUL

NOMAD

SERVERLEADER

SERVERFOLLOWER

SERVERLEADER

SERVERFOLLOWER

SERVERFOLLOWER

SERVERFOLLOWER

NODE A NODE B

GOOGLE CLOUD

NATS CLOUDMESSAGING

REPLICATION

FORWARDING

REPLICATION

FORWARDING

REPLICATION

FORWARDING

REPLICATION

FORWARDING

LOAD BALANCER

LOAD BALANCER

CONSUL

NOMAD

SERVERLEADER

SERVERFOLLOWER

SERVERLEADER

SERVERFOLLOWER

SERVERFOLLOWER

SERVERFOLLOWER

NODE A NODE B

AWS

REPLICATION

FORWARDING

REPLICATION

FORWARDING

REPLICATION

FORWARDING

REPLICATION

FORWARDING

LOAD BALANCER

REGION FORWARDING (VPN)

REGION FORWARDING (VPN)

Page 43: Living the Nomadic life - Nic Jackson

NOMADSCHEDULING

Page 44: Living the Nomadic life - Nic Jackson

44

SCHEDULING

44

Schedulers process evaluations and generate allocation plans.

Placement is determined using the relevant scheduler.

Scheduling involves feasibility checking and ranking.

Feasibility filters out nodes missing necessary drivers and those failing the specified constraints.

Ranking score feasible nodes to find the best fit (bin packing).

Page 45: Living the Nomadic life - Nic Jackson

45

SCHEDULER TYPES

45HashiCorp confidential do not distribute

Service Long-running applications and services

Batch Short-lived data processing jobs (benefit from fast placement)

System Lower level jobs that run on all clients (logging, monitoring)

Page 46: Living the Nomadic life - Nic Jackson

46

$ nomad plan example.nomad+ Job: "example"+ Task Group: "cache" (1 create) + Task: "redis" (forces create)

Scheduler dry-run:- All tasks successfully allocated.

$

Text

SCHEDULING: PLAN

Page 47: Living the Nomadic life - Nic Jackson

47

$ nomad plan example.nomad.java+ Job: "example"+ Task Group: "web" (1 create) + Task: "tomcat" (forces create)

Scheduler dry-run:- WARNING: Failed to place all allocations. Task Group "web" (failed to place 1 allocation): * Constraint "missing drivers" filtered 2 nodes

$

Text

SCHEDULING: PLAN

Page 48: Living the Nomadic life - Nic Jackson

48

$ nomad run example.nomad==> Monitoring evaluation "4b8b7779" Evaluation triggered by job "example" Allocation "38720b8e" created: node "ec2f0830", group "cache" Evaluation status changed: "pending" -> "complete"==> Evaluation "4b8b7779" finished with status "complete"

$

Text

SCHEDULING: RUN

Page 49: Living the Nomadic life - Nic Jackson

49

$ nomad run -region=gcp events.nomad==> Monitoring evaluation "e2a8dfe6" !On branch master Evaluation triggered by job "events" !Your branch is up-to-date with 'origin/master'. Allocation "6615b39f" modified: node "0d6a6103", group "pubsub" !nothing to commit, working tree clean Evaluation status changed: "pending" -> "complete" !==> Evaluation "e2a8dfe6" finished with status "complete"

$

Text

SCHEDULING: RUN DIFFERENT REGION

Page 50: Living the Nomadic life - Nic Jackson

50

$ nomad status exampleID = exampleName = exampleType = servicePriority = 50Datacenters = us-west-1Status = running

SummaryTask Group Queued Starting Running Failed Complete Lostcache 0 0 1 0 0 0

AllocationsID Eval ID Node ID Task Group Desired Status Created At38720b8e 4b8b7779 ec2f0830 cache run running 04/26/17 ...

$

Text

SCHEDULING: STATUS

Page 51: Living the Nomadic life - Nic Jackson

DEMO!

Page 52: Living the Nomadic life - Nic Jackson

NomadMillion ContainerChallenge

1,000 Jobs

1,000 Tasks per Job

5,000 Hosts on GCE

1,000,000 Containers

Page 53: Living the Nomadic life - Nic Jackson

53

MILLION CONTAINER CHALLENGE

53

Page 54: Living the Nomadic life - Nic Jackson

54

MILLION CONTAINER CHALLENGE

54

– Bill Gates

640 KB ought to be enough for anybody.“

Page 55: Living the Nomadic life - Nic Jackson

55

REAL WORLD SCALE

55

2nd Largest Hedge Fund

18K Cores

5 Hours

2,200 Containers/second

Page 56: Living the Nomadic life - Nic Jackson

Q/A AND HASHICONF

Page 57: Living the Nomadic life - Nic Jackson

SEPTEMBER 18-20AUSTIN, TEXASwww.hashiconf.com

#hashiconf�

Page 58: Living the Nomadic life - Nic Jackson

#hashiconf�

Links:

https://www.nomadproject.io

https://github.com/nicholasjackson/terraform-nomad-multi-cloud