chef + aws + codeigniter

26
Chef + AWS + CodeIgniter @_kennyk_

Upload: ciconf

Post on 30-Nov-2014

1.570 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Chef + AWS + CodeIgniter

Chef + AWS + CodeIgniter

@_kennyk_

Page 2: Chef + AWS + CodeIgniter

Me

• Co-authored Sparks• Reactor Engineer• Former Yahoo, Freelancing w/ Mozilla• Closet Ops guy

Page 3: Chef + AWS + CodeIgniter

Deployment Before

• Collection of bash scripts• Not all installed software is known• Homebrew tools (Yahoo’s Taxi, Pogo, Etsy’s

Deployinator)• Didn’t integrate well with infrastructure– Provision new boxes? Probably not

• Terrifying to edit once the guy who wrote it is gone

Page 4: Chef + AWS + CodeIgniter

Now

• Capistrano• Rubber• Puppet• Chef• .. and a bunch more

Page 5: Chef + AWS + CodeIgniter

Why Chef?

• Integration with AWS and Rackspace• Extremely flexible• Platform-agnostic– And linux-variant agnostic

• Code sharing in the community• Very popular• Back by OpsCode, founded by former Amazon

Ops guys

Page 6: Chef + AWS + CodeIgniter

Any Downsides?

• So flexible, so open-ended, big learning curve• 30-40 hours before you feel comfortable– According to me

• You’ll rely on mostly blog posts to get your specific stack running– Or presentations like this

Page 7: Chef + AWS + CodeIgniter

But just imagine …

• Your server stops taking requests• You don’t know why• You can– Run one command that provisions a new box in

AWS with your full stack and configuration– Run commands on all of your nodes at once

Page 8: Chef + AWS + CodeIgniter

Uh yea, so what about Heroku/Pagoda/PHP Fog?

• Just my opinion• When they go down, so do you• You trust Heroku to manage infrastructure

intelligently with a black box• But sometimes they don’t, apparently– Heroku, June xx, whoops

• Don’t be someone else’s bitch

Page 9: Chef + AWS + CodeIgniter

Pre-reqs

• You know a little something about AWS• You’re comfortable with the command line

Page 10: Chef + AWS + CodeIgniter

Demo

Page 11: Chef + AWS + CodeIgniter

By the Way

• You can’t learn what you really need to know in a 45 minute talk

• In ruby– Can still use it without knowing much

Page 12: Chef + AWS + CodeIgniter

Chef Terms (the basics)

• Cookbooks• Recipes• Knife• Roles• Attributes• Environments• Data bags

Page 13: Chef + AWS + CodeIgniter

Cookbooks

• A module for installing and configuring a software package– PHP– Apache2– New Relic monitoring– Your webapp– …

• A cookbook contains at least one recipe

Page 14: Chef + AWS + CodeIgniter

Recipes

• A component of each cookbook– For Apache2• mod_rewrite• mod_php5• …

• Each cookbook has a default recipe

Page 15: Chef + AWS + CodeIgniter

Resources

• Build in tools/building blocks for writing recipes– Need a symlink? Got that– Need an apt package? Got that

• http://wiki.opscode.com/display/chef/Resources

Page 16: Chef + AWS + CodeIgniter

Attributes

• Cascading configuration settings that are used by recipes– What port does Apache listen on?– What user does this process run as?

• You can make anything a setting• Set them at the– Cookbook level (defaults)– Environment level (dev, staging, prod, w/e)– Any role level

Page 17: Chef + AWS + CodeIgniter

Roles (rolls)

• Categories for your servers/nodes• In sophisticated setups– Database server role– Webapp role– Load balancer role– Utility box role

• A single server can play multiple roles– In dev, maybe one box plays all roles to save $

Page 18: Chef + AWS + CodeIgniter

Environments

• Just a container/construct for different env settings

• Each node is assigned an environment on creation

• Can be changed

Page 19: Chef + AWS + CodeIgniter

Data bags

• More settings, usually used for sensitive settings– Database passwords– API keys– …– Settings which aren’t strictly associated with a role

or environment type• Can be encrypted

Page 20: Chef + AWS + CodeIgniter

Actual node

• Has environment• Has run_list– Usually set once on node creation– Recipes– Roles

• Has chef-client installed– Pulls settings– Figures out what’s needed– Installs

Page 21: Chef + AWS + CodeIgniter

Knife

• Command line tool to rule your world• See what your nodes are up to• Search, run remote commands• Deploy at scale– 14,000 adserving nodes?

• Executes in parallel

Page 22: Chef + AWS + CodeIgniter

Hosted Chef

• OpsCode is the central repository for your configuration

• Diagram next slide

Page 23: Chef + AWS + CodeIgniter
Page 24: Chef + AWS + CodeIgniter

Pushing settings

• knife cookbook upload [cookbook]• knife role from file roles/webapp.json• knife data bag from file webapp [path]• knife environment from file [path]

Page 25: Chef + AWS + CodeIgniter

More demo

• Download a community cookbook• Execute in paralell

Page 26: Chef + AWS + CodeIgniter

Thanks!

• @_kennyk_• codefury.net• https://github.com/katzgrau/chef-ec2-

codeigniter-quickstart