the unintended benefits of chef

39
The Unintended Benefits of Chef Standardization FTW

Upload: chef-software-inc

Post on 17-May-2015

696 views

Category:

Technology


0 download

DESCRIPTION

When most people talk about automating infrastructure, they focus on things like consistency, scalability, and flexibility. While fine goals, we recently converted several projects to Chef for both systems AND application deployment, and found that, with a little work, these tools could also help you enable better software quality assurance, load modeling, and even improve resource allocation. By sharing cookbooks across projects, we were able to standardize practices and eliminate arbitrary differences, while using parameterization to perfectly isolate the special needs of each project. This allowed us to transfer knowledge among staff much more quickly. Pulling in and parameterizing application state – database contents, website assets, uploaded content – allowed us to spin up new environments with as much or as little state as needed. Integrating with Vagrant and Jenkins, we were then able to use chef to treat the entire image – system and application – as a test fixture. As each engineer (ops or dev) has visibility into the whole stack, we can more easily move people between dev and ops, or between projects.

TRANSCRIPT

Page 1: The unintended benefits of Chef

The Unintended Benefits of Chef

Standardization FTW

Page 2: The unintended benefits of Chef

whoamiClinton Wolfe, Web Architect @ OmniTI mod perl developer since 1996cheffin' since 2012

@clintoncwolfegithub: clintoncwolfe

LEGO group

Page 3: The unintended benefits of Chef

$JOBomniti.comcustom web development - UX to hostingwe make OmniOS, an Illumos based OS distro

Page 4: The unintended benefits of Chef

our dev clientsmostly brownfield worknew featuresoh no it won't scalemy nephew built it

Page 5: The unintended benefits of Chef

client scalesome have hundreds of nodesmost clients have < 10 nodes

some have many, want fewersome have few, need morewe specialize in doing more with less

mijasper/brickshelf

Page 6: The unintended benefits of Chef

process : anti-processeach customer has "unique" problems

some are, most aren't

we're flexible, urging gradual change

Page 7: The unintended benefits of Chef

TMTOWTDI....dev environmentsasset statecronself-referential urlsCPAN/PECL/gem/egg/npm builds

“You Only Deploy Once!"

Page 8: The unintended benefits of Chef

clients: YODO!!!

except for disaster recovery

Page 9: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devs

Page 10: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devsexcept for CI

Page 11: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devsexcept for CIexcept for scaling out

Page 12: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devsexcept for CIexcept for scaling outexcept for load testing

Page 13: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devsexcept for CIexcept for scaling outexcept for load testingexcept for upgrade testing

Page 14: The unintended benefits of Chef

clients: YODO!!!

except for disaster recoveryexcept for onboarding devsexcept for CIexcept for scaling outexcept for load testingexcept for upgrade testingexcept for datacenter moves

Page 15: The unintended benefits of Chef

QA is hardcan't make new QA environments

QA env is precious

state hard to manage

If testing is hard, no testing is done

mijasper/brickshelf

Page 16: The unintended benefits of Chef

surely we can do better

We want standardization

Client wants deployability (scale-out, resilience)

Chef FTW

Page 17: The unintended benefits of Chef

The Plan!Focus on deployability

Integrate systems and app deployment

Custom Recipes – choosing your battles

Automate testing early

Page 18: The unintended benefits of Chef

cheffing as discoveryExploring the existing app for on-boarding

Even rsyncing a golden image is OK

capture it in chefGet deployable (in Vagrant ) ASAP mijasper/customminifigs.co.uk

Page 19: The unintended benefits of Chef

The Plan!Focus on deployability

Integrate systems and app deployment

Custom Recipes – choosing your battles Automate testing early

Page 20: The unintended benefits of Chef

app deployment in chef?

most app deployment tools partially dictate layout, push process, etc

who knows what we have been handed

but chef can do pretty much anything!

Page 21: The unintended benefits of Chef

cheffing an app

identify and decouple rolessetup user auth, systems stuffcode checkouttemplatize config filesservice definitions

Iterate, standardize, simplify!

Page 22: The unintended benefits of Chef

The Plan!Focus on deployability

Integrate systems and app deployment

Custom Recipes – choosing your battles

Automate testing early

Page 23: The unintended benefits of Chef

finding variances

understand existing variancesstandardize the arbitraryjustify the ones that need to remain

writing a custom cookbook is a red flag

jokeith/brickshelf

Page 24: The unintended benefits of Chef

Our shared cookbooks

Over 20 cookbooks used internally at the company, cross-clientAttribute-driven default recipesExposes project variances in clear relief... yet we can easily extend them if needed

Shared roles/handlers/databags, too

Page 25: The unintended benefits of Chef

it's still OK to punt

We will never be fully standardizedAs old projects mature, new projects arrive

known technical debtcan be healthy

mijasper/brickshelf

Page 26: The unintended benefits of Chef

The Plan!Focus on deployability

Integrate systems and app deployment

Custom Recipes – choosing your battles

Automate testing early

Page 27: The unintended benefits of Chef

cheffing: ci with jenkins

static checks on chef configscratchbuild Vagrant runsparametric builds and Vagrantfilesvagrant-test-subject

mijasper/brickshelf

Page 28: The unintended benefits of Chef

system tests

High-level, near-english behavioral tests

Not low-level unit tests against codebase Supposed to be serving http? Check for it!

Easy to add more later - start with minimum

Page 29: The unintended benefits of Chef

aside: our test harness

vagrant-rspec-ci gemprovision ok?services running?connect to port?Capybara for web UI testingJunit output for pretty Jenkins graphs

Page 30: The unintended benefits of Chef

Test spec exampledescribe "TrafficServer Service" do

before(:all) do

@vm = VagrantTestSubject::VM.attach()

end

it "should appear as a healthy service" do

@vm.should have_running_service("trafficserver")

end

it "should be listening on external_ip:80" do

@vm.should be_listening_on_external_ip(80)

end

it "should be the right process name on port 80" do

process = @vm.process_name_listening('127.0.0.1', 80)

process.should match(/\/opt\/ts\/bin\/traffic_manager/)

end

it "should respond with HTTP 200 to / on port 80" do

@vm.http_get('/').should be_http_not_found # from rspec-http gem

end

end

Page 31: The unintended benefits of Chef

Shiny, Happy TeamsOps Team ImpactDev Team ImpactQA Team ImpactOrganizational Impact

LEGO Group

Page 32: The unintended benefits of Chef

Ops Team ImpactChef everywhere! YAY!

Chef for everything, especially wildly divergent app deployments! BOO!

Direct exposure to dev team deployment needs & tooling... a more devvy ops team

Page 33: The unintended benefits of Chef

Dev Team ImpactCan get a new dev env anytime, have more than one - YAYSame build everywhere – YAYI have to learn ruby? BOOSome awareness of practices on other projects, improved perspectiveMuch more visibility into how systems are provisioned – a more opsy dev team

Page 34: The unintended benefits of Chef

QA Team ImpactUse vagrant VMs as test subjects

QA VM provisioning can now be elastic, responsive to testing/release cycles

Dev and QA exposure to systems BDT

Dev and ops teams more QA-y: devopsqa!

Page 35: The unintended benefits of Chef

the VM as fixture

data loads - vary by test scenariodata loads - vary for scaleasset loadsrole permutationsos, vm, env permutationsclusters of related machines (db, web, CDN, client)

Page 36: The unintended benefits of Chef

aside: loading fixturesWe use Chef roles to define attributes that load fixture state

We use recipes to read the attributes and converge to the needed test state

•special purge-all role clears all state•use env var to pass fixture list into vagrant for

provision

Page 37: The unintended benefits of Chef

i accidentally the whole dbfixture loading must be used with care

use a safety flag to enable it

Nelson Yrizarry/brickshelf

Page 38: The unintended benefits of Chef

Organizational Impact

Standardization eases: actual deployment on-call ops can support the app more devs responsible for deployability ops can participate in app management reduced ramp-up time onto existing projects

Page 39: The unintended benefits of Chef

Thanks!Clinton [email protected]

findmybrick.com