managing distributed systems with chef

35
Managing Distributed Systems with Chef Mandi Walls [email protected] RiCon 2012 October 10, 2012

Upload: mandi-walls

Post on 29-Jan-2018

3.548 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Managing Distributed Systems with Chef

Managing Distributed Systems with Chef

Mandi [email protected]

RiCon 2012October 10, 2012

Page 2: Managing Distributed Systems with Chef

whoami

• Senior Technical Evangelist (Consultant) at Opscode

• @lnxchk

[email protected]

Page 3: Managing Distributed Systems with Chef

Chef

• Configuration management system built with the cloud in mind

• http://www.opscode.com

Page 5: Managing Distributed Systems with Chef

Quick Chef Bits

• Resources: things you manage (files, directories, services)

• Nodes: hosts you manage, run chef-client

• Recipes: collections of resources

• Templates: dynamically generate configuration

• Cookbooks: packages for recipes, usually a functional piece of software

• Chef Server: stores info, cookbooks, runs an API and a search engine

Page 6: Managing Distributed Systems with Chef

What is a Distributed System

“A distributed system is a collection of independent computers that appears to its users as a single coherent system”

~ Tanenbaum and van Steen, Distributed Systems, 2002

Page 7: Managing Distributed Systems with Chef

What Do You Distribute?

• Hits: with a load balancer

• Reads: with some slaves

• Workload: with some compute nodes

• Storage: with some storage nodes

Page 8: Managing Distributed Systems with Chef

Infrastructure Management

• Complex distributed systems require the proper tools to configure them to meet their goals

• Distributed systems are built by connecting bricks together in pleasing landscapes

http://www.flickr.com/photos/53486765@N02/

Page 9: Managing Distributed Systems with Chef

How Do You Distribute?

• Client-Server N:1

• Master-Slave-Client: 1:N:M

• Mesh or Cluster: N!

• omg science

Page 10: Managing Distributed Systems with Chef

Goals

• Create system topologies that are as complex as needed to meet the requirements of my architecture

• Allow configurations to dynamically update when nodes join or disappear

Page 11: Managing Distributed Systems with Chef

N:1 Client Server

• Basic examples

• Load balancer finding web nodes

• Application servers finding a datastore

Page 12: Managing Distributed Systems with Chef

example: Load Balancer

• Using Chef roles

• Roles are essentially used to create types of nodes

• I want a webserver, I create a webserver role that includes stuff like Apache, or nginx, or php, or whatever I need

• The webserver I build today using the role will be the same as the one I build next week or next month

• Roles are searchable!

Page 13: Managing Distributed Systems with Chef

Chef Roles

Page 14: Managing Distributed Systems with Chef

example: Load Balancer

Page 15: Managing Distributed Systems with Chef

example: App Servers and Data

• Maybe I don’t want my servers to dynamically go looking for an element

• I want to be able to tell them where to find it

• Use Chef attributes

Page 16: Managing Distributed Systems with Chef

Chef Attributes

Page 17: Managing Distributed Systems with Chef

example: App Servers and Data

Page 18: Managing Distributed Systems with Chef

example: App Servers and Data

Page 19: Managing Distributed Systems with Chef

Master:Slaves:Clients

• Services in complex topologies have more than one access pattern

• Combinations of Chef Roles and Attributes create more interesting relationships

Page 20: Managing Distributed Systems with Chef

Master Role

Page 21: Managing Distributed Systems with Chef

Slave Role

Page 22: Managing Distributed Systems with Chef

Client Role

Page 23: Managing Distributed Systems with Chef

What Was All That?

Page 24: Managing Distributed Systems with Chef

Clusters

• Complex topologies in which every component should know about all or most of the other components

Page 25: Managing Distributed Systems with Chef

Clusters Using Environments

• Chef Environments allow you to logically partition your infrastructure

• Canonical example is a Dev/Test/Stage/Prod model

• But!

• Create a logical group dedicated to your cluster

Page 26: Managing Distributed Systems with Chef

Chef Environments

Page 27: Managing Distributed Systems with Chef

Environments in Recipes

• Nodes belonging to the mob environment will have tony as their boss

• Nodes belonging to the herd environment will have cowboy as their boss

• The same software can be used to manage these two clusters, and their environments keep them together

Page 28: Managing Distributed Systems with Chef

Chef Databags

• “Bags of Holding”

• Whatever random kind of stuff you need to share, in JSON

• Not limited to cookbooks, roles, recipes: global data

• Usually you want them to be saved in your source repository

• Set of directories and files like data_bags/clusters/herd.json and data_bags/clusters/mob.json

Page 29: Managing Distributed Systems with Chef

Writing to Databags from Nodes

• Little bit dangerous

• Little bit racy

http://www.gcpvd.org/2011/09/27/riverzedge-industrial-ball-and-sander-drag-races-october-14/

Page 30: Managing Distributed Systems with Chef

Clusters Using Databags• Update the cluster’s databag in real time from the nodes

• Let’s say the herd cluster elected sheepdog as its boss instead of cowboy

• We could write a piece of node data and search, or we could abuse a databag

Page 31: Managing Distributed Systems with Chef

Write a Databag Item

• Write out a new value in the clusters databag, herd item

Page 32: Managing Distributed Systems with Chef

Read Databag Items• The rest of the herd will get the new value by reading it out of the

databag

• The convergence interval is as long as you wait between chef-client executions on the nodes

Page 33: Managing Distributed Systems with Chef

Things to Consider

• Your nodes converge by running the chef-client agent

• chef-client can be run on an interval, or on demand

Page 34: Managing Distributed Systems with Chef

Other Chefy Things

• Start, Report, and Error Handlers

• Lightweight Resources and Providers

• http://wiki.opscode.com

Page 35: Managing Distributed Systems with Chef

Thanks!

• http://www.opscode.com

• http://community.opscode.com

• @lnxchk

[email protected]