Slide 1

Slide 1 text

What is Chef.. ..and how we use it at

Slide 2

Slide 2 text

Who am I? Giedrius Rimkus Lithuanian PHP Developer at tripsta Ruby enthusiast Basketball lover @giedriusr

Slide 3

Slide 3 text

I'll be talking about.. Sentiments Pain Solution

Slide 4

Slide 4 text

Back in 2009..

Slide 5

Slide 5 text

Infrastructure Application

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Infrastructure Application

Slide 8

Slide 8 text

Infrastructure Application Application Database

Slide 9

Slide 9 text

Infrastructure Application Application Application Database

Slide 10

Slide 10 text

Infrastructure Application Application Application Database Application Application

Slide 11

Slide 11 text

Infrastructure Application Application Application Database Application Application API LB API LB

Slide 12

Slide 12 text

Complexity

Slide 13

Slide 13 text

Pain ○ Long installation process ○ Hard maintenance ○ Scaling issues ○ Constantly increased load and usage of resources (no load balancer)

Slide 14

Slide 14 text

Solution

Slide 15

Slide 15 text

CLUSTER

Slide 16

Slide 16 text

WTH IS CLUSTER?

Slide 17

Slide 17 text

What is a Cluster? It's a group of linked computers, working together closely thus in many respects forming a single computer.

Slide 18

Slide 18 text

Cluster categories High-availability (HA) clusters High-availability clusters (also known as failover cluster) are implemented primarily for the purpose of improving the availability of services that the cluster provides. Load-balancing clusters Load-balancing is when multiple computers are linked together to share computational workload or function as a single virtual computer. Logically, from the user side, they are multiple machines, but function as a single virtual machine. Compute clusters Somes times called as a “Grid computing”. Basically used for calculating huge stats, etc.

Slide 19

Slide 19 text

HOW TO BUILD IT?

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

OR

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

What is Chef? What problem does it solve? Chef is an open-source systems integration framework built specifically for automating the cloud / system configuration.

Slide 28

Slide 28 text

Chef types Chef Solo Chef client and Chef server Hosted Chef Private Chef

Slide 29

Slide 29 text

Chef Solo.. ..is an open source standalone version of Chef that runs locally on your node, detached from a Chef server.

Slide 30

Slide 30 text

Chef Client and Chef Server Chef-client connects to a Chef Server to be told what to do on the node.

Slide 31

Slide 31 text

Hosted Chef As with Chef-Server, Chef-client connects to Hosted Chef to be told what to do on the local node.

Slide 32

Slide 32 text

Private Chef.. ..is for Enterprises who want the power, flexibility, availability, and performance of Hosted Chef, but require that information never leave their private networks.

Slide 33

Slide 33 text

Why it's an issue? Infrastructure changes all the time. Different operating systems Different hardware from different vendors.

Slide 34

Slide 34 text

What exactly can you do with Chef? ● Install Operating Systems on new servers. ● Install application software on servers. ● Have new software automatically configure itself to match your environment. ● Share recipes (and obtain recipes from) other people to install and configure software.

Slide 35

Slide 35 text

Some goodies I like about Chef "Manage your servers by writing code, not by running commands." Chef is idempotent Built on top of Ruby

Slide 36

Slide 36 text

Chef Server Architecture

Slide 37

Slide 37 text

Architecture visualization

Slide 38

Slide 38 text

Basic structure of Chef Environments Nodes Cookbooks Recipes Files / Templates Attributes Data Bags Search

Slide 39

Slide 39 text

What is what? What is recipe? What is cookbook? What is resource? What is node? What is chef-client? What is knife? What is data bag? What is template?

Slide 40

Slide 40 text

Modeling your infrastructure

Slide 41

Slide 41 text

Nodes A node is a host that runs the Chef client. The primary features of a node, from Chef's point of view, are its attributes and its run list. Nodes are the thing that Recipes and Roles are applied to.

Slide 42

Slide 42 text

Roles A role means grouping similar features of similar nodes.

Slide 43

Slide 43 text

Run list A list of recipes that a node will run.

Slide 44

Slide 44 text

Configuring Nodes

Slide 45

Slide 45 text

Cookbooks A cookbook is a collection of recipe, resource definition, attribute, library, cookbook file and template files that chef uses to configure a system. Cookbooks are typically grouped around configuring a single package or service. The MySQL cookbook, for example, contains recipes for both client and server.

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Recipes Recipes are the files where you write your resources (code).

Slide 48

Slide 48 text

Another example chef/cookbooks/git/recipes/default.rb package "git-core" # apt-get install git-core # yum install git-core # etc..

Slide 49

Slide 49 text

Another example directory "/home/new_folder" do mode 0755 owner "someuser" group "www" action :create end

Slide 50

Slide 50 text

Metadata Cookbooks often rely on other cookbooks for pre-requisite functionality. In order for the server to know which cookbooks to ship to a client, a cookbook that depends on another one needs to express that dependency somewhere. That "somewhere" is in cookbook metadata.

Slide 51

Slide 51 text

Resources A resource is usually a cross platform abstraction of the thing you're configuring on the host. Chef's resources are mostly just containers for data, with some basic validation functionality.

Slide 52

Slide 52 text

Resources Have a type Have a name Have parameters Take action to put the resource in the declared state

Slide 53

Slide 53 text

Type

Slide 54

Slide 54 text

Name

Slide 55

Slide 55 text

Parameters

Slide 56

Slide 56 text

Action

Slide 57

Slide 57 text

Providers The provider is the platform-specific implementation of the thing a resource abstracts. On Red Hat or CentOS - yum Debian and Ubuntu - apt package manager will be used

Slide 58

Slide 58 text

Search Search is built by the Chef Server, and allow you to query arbitrary data about your infrastructure

Slide 59

Slide 59 text

Data Bags Data Bags store nested key–value data on the chef server. Data Bag data are searchable, and can also be loaded directly by name in a recipe. Data Bags are global for your chef- server installation–you can think of them as attributes for your whole infrastructure.

Slide 60

Slide 60 text

Environments Provides a mechanism for managing different architectural segmented spaces such as production, staging, development, and testing, etc with one Chef setup.

Slide 61

Slide 61 text

Chef Workflow

Slide 62

Slide 62 text

Everyday Chef Workflow for developers

Slide 63

Slide 63 text

Developer makes changes to Chef recipes, roles, etc.

Slide 64

Slide 64 text

Developer pushes changes to origin Chef repository

Slide 65

Slide 65 text

Developer uses Knife to push new code to the Chef Server

Slide 66

Slide 66 text

Developer uses Knife to tell Chef-clients to update themselves

Slide 67

Slide 67 text

Chef-client on Chef nodes contact the Chef Server

Slide 68

Slide 68 text

Chef-client pulls latest code from the Chef Server

Slide 69

Slide 69 text

Chef-client on the node updates the system

Slide 70

Slide 70 text

Practical example

Slide 71

Slide 71 text

Update authorized_keys $ echo 'ssh-rsa dev4-public-key' >> !$ $ cat cookbooks/bootstrap/files/default/authorized_keys

Slide 72

Slide 72 text

Committing and pushing $ git diff git add . git commit -m 'adding new public key' git push

Slide 73

Slide 73 text

Updating Chef Server bundle exec knife cookbook upload bootstrap cap configure:all or ssh [email protected] $ chef-client

Slide 74

Slide 74 text

How Chef helped us?

Slide 75

Slide 75 text

We don't care that much about Infrastructure changes all the time Scalability, because.. - adding new nodes is painless - it's fast (takes minutes or hours, not days or weeks) - there is no need in buying more machines with every new website

Slide 76

Slide 76 text

Clear separation between servers with roles: Frontend Backend Application Memcached Database other..

Slide 77

Slide 77 text

Chef requirements Chef-client is supported on the following platforms ● Ubuntu (10.04, 10.10, 11.04, 11.10) ● Debian (5.0, 6.0) ● RHEL & CentOS (5.x, 6.x) ● Fedora 10+ ● Mac OS X (10.4, 10.5, 10.6, 10.7) ● Windows 7 ● Windows Server 2003 R2, 2008 R2 Ruby Ruby 1.8.7, 1.9.1 or 1.9.2 with SSL bindings is required. RubyGems Version 1.3.7 or greater. On Ubuntu and Debian Rubygems should be installed from source Git?

Slide 78

Slide 78 text

Parts I didn't cover - Setting up and running chef-server / chef-client - Shef - Knife plugins - Chef + capistrano - All the rest Chef goodies

Slide 79

Slide 79 text

Chef Alternatives ● Puppet ● Sprinkle ● Rubber ● Sunzi

Slide 80

Slide 80 text

Great resources https://github.com/opscode/cookbooks http://wiki.opscode.com/display/chef/Home http://railscasts.com/episodes/339-chef-solo-basics https://github.com/ctshryock/capistrano-chef

Slide 81

Slide 81 text

Thank You

Slide 82

Slide 82 text

No content