39
Bots Not Cattle Josh Berkus Red Hat Automacon PDX September 2016

Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

  • Upload
    others

  • View
    32

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Bots Not Cattle

Josh BerkusRed HatAutomacon PDXSeptember 2016

Page 2: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 3: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

HA Postgres

Page 4: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

third wave of automation?

1. software packages & BASH2. configuration management3. ???

Page 5: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

third wave of automation?

1. software packages & BASH2. configuration management3. container orchestration?

Page 6: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

third wave of automation?

1. software packages2. a. configuration management

b. container orchestration

Page 7: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

third wave of automation?

1. software packages2. a. configuration management

b. container orchestration3. ???

Page 8: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 9: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 10: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

the problemwith cattle

● dumb● move only in one

direction● require (smart) central

management

Page 11: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

central management limits● infrastructure scale● people scale (dev/ops split)● communications lag● application event response

Page 12: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 13: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 14: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 15: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 16: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

intelligent “bots”● capable of reacting to

deployment, configuration, and availability events

● programmed to "do the right thing" in each case

Page 17: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their
Page 18: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

state machines

Page 19: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

state machines

Page 20: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

state machines

● simpler, testable logic● avoid unhandled events● much simpler scheduling

Page 21: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

patroni: postgres automation

Cluster 1AStartup

State 0

Cluster 1AReplica

State 1b

Transition

Start Replication

Master Found

Page 22: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Cluster 1AStartup

State 0

Page 23: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Cluster 1AStartup

State 0

Cluster 1AMaster

State 1a

Transition

Initialize

FailedMaster Check

Page 24: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Cluster 1AStartup

State 0

Cluster 1AReplica

State 1b

Transition

Start Replication

Master Found

Page 25: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Cluster 1AReplica

Master CheckPassed

Page 26: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

Cluster 1AMaster

Cluster 1AReplica

State 1b

Transition

Leader Election

FailedMaster Check

State 1a

Page 27: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

automate the application,not the system

bots

Page 28: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

new bot rules

1. bots initialize themselves2. bots know their own state3. bots share their state4. bots change their state in response to

events

Page 29: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

new bot rules

1. self-configuration2. local state store3. distributed configuration4. event-driven response loop

Page 30: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

new bot rules

1. sophisticated init code2. local daemon which maintains state3. write state to etcd4. watch etcd for changes

Page 31: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

bot-ish platforms● Postgres: patroni, manatee, flynn.io● Chef Habitat● Kubernetes custom schedulers● Mesos Frameworks

Page 32: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

boticizing● How can it initialize and

self-configure?● How can it store state about its part

of the infrastructure?● Use a DCS to share state.● Rewrite management as a set of state

transitions.

Page 33: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

boticizing a web app: init

1. initialize with DCS connection & node name

2. query DCS for DB connection & CDN3. pull new code from git4. launch5. update DCS with state

Page 34: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

bot problems● lagginess:

event watch, gossip● race conditions: DCS locking● resource usage:

resource events?● frameworks for writing state

machines?

Page 35: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

devs need to automate

Page 36: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

devs need to automate

¯\_(ツ )_/¯

we're all DevOps now

Page 37: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

let's build some bots!

Josh BerkusRed HatAutomacon PDXSept. 2016

Page 38: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

let's build some bots!

Contact● [email protected]● @fuzzychef● www.projectatomic.io

Events● Cloud Native PDX

Meetup● KubeCon Nov. 7,

Seattle

Page 39: Bots Not Cattle - GitHub Pagesjberkus.github.io/pdf_presos/bots_not_cattle_automacon.pdfnew bot rules 1. bots initialize themselves 2. bots know their own state 3. bots share their

the fine print

This presentation is copyright 2016 Josh Berkus, and is released under the Creative Commons Share-Alike v3 license, excepting the following images, most used as parody, which are not covered by that license:

● Images of Dr. Who and K-9 are property of the BBC● Images of RoboRally and the RoboRally game are copyright Avalon Hill● The Sorceror's Apprentice and Yoda are copyright Disney, Inc.● The Slonik logo is property of the PostgreSQL Community Associaton of Canada● The IFTTT and Red Hat logos are property of those companies● The Cattle, Not Pets slide is courtesy @joehack3r