97
Towards FutureOps: Stable, repeatable, environments from dev to prod.

Mitchell Hashimoto, HashiCorp

  • Upload
    ontico

  • View
    5.364

  • Download
    2

Embed Size (px)

DESCRIPTION

HighLoad++ 2013

Citation preview

Page 1: Mitchell Hashimoto, HashiCorp

Towards FutureOps: Stable, repeatable, environments from dev to prod.

Page 2: Mitchell Hashimoto, HashiCorp

I’m Mitchell HashimotoAlso known as @mitchellh

Page 3: Mitchell Hashimoto, HashiCorp

I build toolshttp://hashicorp.com

Page 4: Mitchell Hashimoto, HashiCorp

Vagranthttp://www.vagrantup.com

Packerhttp://www.packer.io

SERFhttp://www.serfdom.io

Page 5: Mitchell Hashimoto, HashiCorp

History of OpsOr, the history of pretending that anything works.

Page 6: Mitchell Hashimoto, HashiCorp

Single Dedicated Server

Page 7: Mitchell Hashimoto, HashiCorp

Single Dedicated Server• Manually setup

Page 8: Mitchell Hashimoto, HashiCorp

Single Dedicated Server• Manually setup • Expensive to replace

(time and money)

Page 9: Mitchell Hashimoto, HashiCorp

Single Dedicated Server• Manually setup • Expensive to replace

(time and money) • Professionals, usually

Page 10: Mitchell Hashimoto, HashiCorp

What is hard/slow/expensive?• Acquiring hardware • Manual setup • Expertise • Downtime, Failures

Page 11: Mitchell Hashimoto, HashiCorp

Multiple Dedicated Servers

Page 12: Mitchell Hashimoto, HashiCorp

Multiple Dedicated Servers• Golden images

Page 13: Mitchell Hashimoto, HashiCorp

Multiple Dedicated Servers• Golden images • Manually made

Page 14: Mitchell Hashimoto, HashiCorp

Multiple Dedicated Servers• Golden images • Manually made • Slow to change,

expensive to grow

Page 15: Mitchell Hashimoto, HashiCorp

Multiple Dedicated Servers• Eventually: config

management (CFEngine, Puppet, Chef)

Page 16: Mitchell Hashimoto, HashiCorp

What is hard/slow/expensive?• Acquiring hardware • Making images • Expertise • Downtime, Failures

Page 17: Mitchell Hashimoto, HashiCorp

The Low-Cost VPS Server

Page 18: Mitchell Hashimoto, HashiCorp

The VPS Server• Manually made (cargo

cult, usually)

Page 19: Mitchell Hashimoto, HashiCorp

The VPS Server• Manually made (cargo

cult, usually) • Cheaper to replace

Page 20: Mitchell Hashimoto, HashiCorp

The VPS Server• Manually made (cargo

cult, usually) • Cheaper to replace • Hobbyist, startup

Page 21: Mitchell Hashimoto, HashiCorp

What is hard/slow/expensive?• Expertise • Downtime, Failures • Rebuilding it

Page 22: Mitchell Hashimoto, HashiCorp

The Cloud

Page 23: Mitchell Hashimoto, HashiCorp

The Cloud• Many cheap servers

Page 24: Mitchell Hashimoto, HashiCorp

The Cloud• Many cheap servers • Seconds to create

Page 25: Mitchell Hashimoto, HashiCorp

The Cloud• Many cheap servers • Seconds to create • Configuration

management

Page 26: Mitchell Hashimoto, HashiCorp

• Configuration mgmt • Portability • Repeatability • Can be expensive

What is hard/slow/expensive?

Page 27: Mitchell Hashimoto, HashiCorp

The Ops of TomorrowBetter, faster, stronger

Page 28: Mitchell Hashimoto, HashiCorp

Immutable Infrastructure

Page 29: Mitchell Hashimoto, HashiCorp

Immutable InfrastructureInstead of modifying or maintaining a server, replace it with a new one.

Page 30: Mitchell Hashimoto, HashiCorp

Immutable InfrastructureServers don’t change anymore, they’re pre-built, static images that are tested/verified.

Page 31: Mitchell Hashimoto, HashiCorp

Immutable Wins• Super fast server deployment • Failure expected, not a big deal • Testable, more stable

Page 32: Mitchell Hashimoto, HashiCorp

Automation Critical• Machine Images • Software install/configure • Failure detection, recovery • etc…

Page 33: Mitchell Hashimoto, HashiCorp

Machine ImagesEasily build machine images for multiple platforms with Packer.

Page 34: Mitchell Hashimoto, HashiCorp

Machine image: A single deployable unit that contains a pre-configured OS and software.

Page 35: Mitchell Hashimoto, HashiCorp

Ew... Images.The anti-image stigma

Page 36: Mitchell Hashimoto, HashiCorp

DevOps has historically been against machine images.

Page 37: Mitchell Hashimoto, HashiCorp

Important to understand why DevOps has historically been against machine images.

Page 38: Mitchell Hashimoto, HashiCorp

Golden images used to be the way.

Page 39: Mitchell Hashimoto, HashiCorp

Quarterly, unchanged, blessed image.

Page 40: Mitchell Hashimoto, HashiCorp

Getting any changes (ops or dev) in was slow and frustrating.

Page 41: Mitchell Hashimoto, HashiCorp

Necessary evil while tooling wasn’t as good as it is today.

Page 42: Mitchell Hashimoto, HashiCorp

With modern config management, easy to simply ignore images.

Page 43: Mitchell Hashimoto, HashiCorp

Machine images also have a ton of benefits.

Page 44: Mitchell Hashimoto, HashiCorp

Super fast infrastructure deployment.

Page 45: Mitchell Hashimoto, HashiCorp

Multi-cloud portability

Page 46: Mitchell Hashimoto, HashiCorp

Stability and Testability

Page 47: Mitchell Hashimoto, HashiCorp

Analogy: Ops without machine images is like applications without binaries

Page 48: Mitchell Hashimoto, HashiCorp

Put it another way: There is no promise of reproducible builds in ops, and no binary-like snapshots

Page 49: Mitchell Hashimoto, HashiCorp

Source Code Binary

Page 50: Mitchell Hashimoto, HashiCorp

Source Code Binary

libA 1.0 libB 1.0 libC 1.0

Page 51: Mitchell Hashimoto, HashiCorp

Source Code Binary

libA 2.0 libB 1.0 libC 1.0

Page 52: Mitchell Hashimoto, HashiCorp

Source Code COMPILE FAILED

libA 2.0 libB 1.0 libC 1.0

Page 53: Mitchell Hashimoto, HashiCorp

New Server Ready Server

Chef, Puppet, Scripts, etc.

Page 54: Mitchell Hashimoto, HashiCorp

New Server Ready Server

Packages NetworkChef/Puppet

Changes

Chef, Puppet, Scripts, etc.

Page 55: Mitchell Hashimoto, HashiCorp

New Server

NetworkChef/Puppet

Changes

Chef, Puppet, Scripts, etc.

Package Changes

SERVER SETUP FAILED

Page 56: Mitchell Hashimoto, HashiCorp

New Server

PackagesChef/Puppet

Changes

Chef, Puppet, Scripts, etc.

Network Unreliable

SERVER SETUP FAILED

Page 57: Mitchell Hashimoto, HashiCorp

New Server

Packages Network

Chef, Puppet, Scripts, etc.

Chef/Puppet Changed

SERVER SETUP FAILED

Page 58: Mitchell Hashimoto, HashiCorp

New Server Ready Server

Machine Image

Page 59: Mitchell Hashimoto, HashiCorp

New Server Ready Server

Machine Image

Page 60: Mitchell Hashimoto, HashiCorp

PackerEmbraces modern best practices and automates building images

Page 61: Mitchell Hashimoto, HashiCorp

Takes template input and repeatably produces image output.

Page 62: Mitchell Hashimoto, HashiCorp

$ packer build \! -var ‘aws_access_key=YOUR KEY’ \! -var ‘aws_secret_key=YOUR SECRET’ \! template.json!...

Page 63: Mitchell Hashimoto, HashiCorp

Automated, repeatable, fast, uses Chef/Puppet/Shell/etc. Gets rid of old downsides.

Page 64: Mitchell Hashimoto, HashiCorp

Can also produce Vagrant boxes for development, at the same time.

Page 65: Mitchell Hashimoto, HashiCorp

WorkflowsWhat does this look like in practice?

Page 66: Mitchell Hashimoto, HashiCorp

Ops Push

Packer Build

Machine Image(s)

Ops

Page 67: Mitchell Hashimoto, HashiCorp

Ops Push

Packer Build

Machine Image(s)

Ops

Setup users, install software, configure software, configure

services. No orchestration.

Page 68: Mitchell Hashimoto, HashiCorp

Request Server

Running Server

Server Deploy

Page 69: Mitchell Hashimoto, HashiCorp

Request Server

Running Server

Server Deploy• Server started with Packer-

built image

• Running server has all pre-installed software

• Service orchestration runs now

Page 70: Mitchell Hashimoto, HashiCorp

“vagrant up”

Ready to work

Development

Page 71: Mitchell Hashimoto, HashiCorp

“vagrant up”

Ready to work

Development• Vagrant downloads the latest

machine image created by Packer

• “vagrant up” takes seconds to minutes and runs, nearly identical to production

Page 72: Mitchell Hashimoto, HashiCorp

Packer Wins• Automated, repeatable images • Fast deployment from dev to prod • Testable, very stable • Embraces configuration mgmt

Page 73: Mitchell Hashimoto, HashiCorp

SERFService orchestration, discovery, failure detection.

Page 74: Mitchell Hashimoto, HashiCorp

Remember, Chef/Puppet/etc. aren’t doing service orchestration for the image.

Page 75: Mitchell Hashimoto, HashiCorp

Service Discovery: Web servers in a load balancer, Memcache in a cluster, MySQL master/slave, etc.

Page 76: Mitchell Hashimoto, HashiCorp

Service Orchestration: Add this node to your cluster, deploy this application, restart, etc.

Page 77: Mitchell Hashimoto, HashiCorp

Serf is a decentralized, highly available, fault tolerant, and lightweight solution to service orchestration and discovery.

Page 78: Mitchell Hashimoto, HashiCorp

ExampleWeb servers in a load balancer

Page 79: Mitchell Hashimoto, HashiCorp

Run the Agent$ serf agent \!! -event-handler=“handle.sh”!…

Page 80: Mitchell Hashimoto, HashiCorp

Join a Cluster$ serf join 10.0.1.5!…

Page 81: Mitchell Hashimoto, HashiCorp

Serf Agent

Handle.sh

Serf Events

Add or Remove Node from LB

Page 82: Mitchell Hashimoto, HashiCorp

Serf Agent

handle.sh

Serf Events

Add or Remove Node from LB

Serf invokes event handlers for any event: member-join, member-leave, member-failed, user.

Page 83: Mitchell Hashimoto, HashiCorp

How?How does Serf do what it does?

Page 84: Mitchell Hashimoto, HashiCorp

GOSSIP-BASED MEMBERSHIP

Page 85: Mitchell Hashimoto, HashiCorp

FAILURE DETECTION

Page 86: Mitchell Hashimoto, HashiCorp

CUSTOM EVENTS

Page 87: Mitchell Hashimoto, HashiCorp

Chef/Puppet Run

Configure Serf Agent Services

Config Management

Don’t start Serf. Serf starts on boot.

Page 88: Mitchell Hashimoto, HashiCorp

Chef/Puppet Run

Configure Serf agent init script

Config Management

Don’t start Serf. Serf starts on boot.

Chef and Puppet just configure the Serf init script to start the agent.

Page 89: Mitchell Hashimoto, HashiCorp

Serf Wins• No orchestration in image build • Fast membership detection, don’t

wait for Chef/Puppet • Easily and infinitely extensible

Page 90: Mitchell Hashimoto, HashiCorp

The Future is ImmutableBig wins, little downsides.

Page 91: Mitchell Hashimoto, HashiCorp

As servers become cheaper, more on-demand, and infrastructures become more distributed, immutable infrastructure will win.

Page 92: Mitchell Hashimoto, HashiCorp

Important to remember:You don’t have to go all in on immutable. You can start with certain servers. Example: databases are hard, just ignore that for awhile.

Page 93: Mitchell Hashimoto, HashiCorp

Mostly ImmutableThere are still big benefits for going mostly immutable. Things like quick config changes and deploys can still be mutable. Serf is good for this.

Page 94: Mitchell Hashimoto, HashiCorp

The Wins• Super fast deployment • Repeatability • High failure tolerance • Improved stability and testability • Versioning

Page 95: Mitchell Hashimoto, HashiCorp

The Downsides• Requires proper mindset • Tooling is new • Deploys, simple config changes

Page 96: Mitchell Hashimoto, HashiCorp

Thank you!

Page 97: Mitchell Hashimoto, HashiCorp

Vagranthttp://www.vagrantup.com

Packerhttp://www.packer.io

SERFhttp://www.serfdom.io