What is Chef and how we use it at tripsta
-
Upload
giedrius-rimkus -
Category
Technology
-
view
1.851 -
download
0
description
Transcript of What is Chef and how we use it at tripsta
![Page 1: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/1.jpg)
What is Chef....and how we use it at
![Page 2: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/2.jpg)
Who am I?Giedrius Rimkus
LithuanianPHP Developer at tripsta
Ruby enthusiastBasketball lover
@giedriusr
![Page 3: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/3.jpg)
I'll be talking about..
Sentiments Pain Solution
![Page 4: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/4.jpg)
Back in 2009..
![Page 5: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/5.jpg)
Infrastructure
Application
![Page 6: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/6.jpg)
![Page 7: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/7.jpg)
Infrastructure
Application
![Page 8: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/8.jpg)
Infrastructure
ApplicationApplication Database
![Page 9: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/9.jpg)
Infrastructure
ApplicationApplication Application
Database
![Page 10: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/10.jpg)
Infrastructure
ApplicationApplication Application
DatabaseApplication Application
![Page 11: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/11.jpg)
Infrastructure
ApplicationApplication Application
DatabaseApplication Application
APILB
APILB
![Page 12: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/12.jpg)
Complexity
![Page 13: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/13.jpg)
Pain
○ Long installation process○ Hard maintenance○ Scaling issues○ Constantly increased load and usage of
resources (no load balancer)
![Page 14: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/14.jpg)
Solution
![Page 15: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/15.jpg)
CLUSTER
![Page 16: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/16.jpg)
WTH IS CLUSTER?
![Page 17: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/17.jpg)
What is a Cluster?
It's a group of linked computers, working together closely thus in many respects forming a single computer.
![Page 18: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/18.jpg)
Cluster categories
High-availability (HA) clustersHigh-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 clustersLoad-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 clustersSomes times called as a “Grid computing”. Basically used for calculating huge stats, etc.
![Page 19: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/19.jpg)
HOW TO BUILD IT?
![Page 20: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/20.jpg)
![Page 21: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/21.jpg)
OR
![Page 22: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/22.jpg)
![Page 23: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/23.jpg)
![Page 24: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/24.jpg)
![Page 25: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/25.jpg)
![Page 26: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/26.jpg)
![Page 27: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/27.jpg)
What is Chef? What problem does it solve?
Chef is an open-source systems integration framework built specifically for automating the cloud / system configuration.
![Page 28: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/28.jpg)
Chef types
Chef Solo Chef client and Chef server Hosted Chef Private Chef
![Page 29: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/29.jpg)
Chef Solo..
..is an open source standalone version of Chef that runs locally on your node, detached from a Chef server.
![Page 30: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/30.jpg)
Chef Client and Chef Server
Chef-client connects to a Chef Server to be told what to do on the node.
![Page 31: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/31.jpg)
Hosted Chef
As with Chef-Server, Chef-client connects to Hosted Chef to be told what to do on the local node.
![Page 32: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/32.jpg)
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.
![Page 33: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/33.jpg)
Why it's an issue?
Infrastructure changes all the time.Different operating systemsDifferent hardware from different vendors.
![Page 34: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/34.jpg)
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.
![Page 35: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/35.jpg)
Some goodies I like about Chef
"Manage your servers by writing code, not by running commands." Chef is idempotent Built on top of Ruby
![Page 36: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/36.jpg)
Chef Server Architecture
![Page 37: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/37.jpg)
Architecture visualization
![Page 38: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/38.jpg)
Basic structure of Chef
EnvironmentsNodesCookbooksRecipesFiles / TemplatesAttributesData BagsSearch
![Page 39: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/39.jpg)
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?
![Page 40: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/40.jpg)
Modeling your infrastructure
![Page 41: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/41.jpg)
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.
![Page 42: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/42.jpg)
Roles
A role means grouping similar features of similar nodes.
![Page 43: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/43.jpg)
Run list
A list of recipes that a node will run.
![Page 44: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/44.jpg)
Configuring Nodes
![Page 45: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/45.jpg)
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.
![Page 46: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/46.jpg)
![Page 47: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/47.jpg)
Recipes
Recipes are the files where you write your resources (code).
![Page 48: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/48.jpg)
Another example
chef/cookbooks/git/recipes/default.rb package "git-core" # apt-get install git-core# yum install git-core# etc..
![Page 49: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/49.jpg)
Another example
directory "/home/new_folder" domode 0755owner "someuser"group "www"action :create
end
![Page 50: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/50.jpg)
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.
![Page 51: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/51.jpg)
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.
![Page 52: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/52.jpg)
Resources
Have a typeHave a nameHave parametersTake action to put the resource in the declared state
![Page 53: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/53.jpg)
Type
![Page 54: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/54.jpg)
Name
![Page 55: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/55.jpg)
Parameters
![Page 56: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/56.jpg)
Action
![Page 57: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/57.jpg)
Providers
The provider is the platform-specific implementation of the thing a resource abstracts. On Red Hat or CentOS - yumDebian and Ubuntu - apt package manager will be used
![Page 58: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/58.jpg)
Search
Search is built by the Chef Server, and allow you to query arbitrary data about your infrastructure
![Page 59: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/59.jpg)
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.
![Page 60: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/60.jpg)
Environments
Provides a mechanism for managing different architectural segmented spaces such as production, staging, development, and testing, etc with one Chef setup.
![Page 61: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/61.jpg)
Chef Workflow
![Page 62: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/62.jpg)
Everyday Chef Workflow for developers
![Page 63: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/63.jpg)
Developer makes changes to Chef recipes, roles, etc.
![Page 64: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/64.jpg)
Developer pushes changes to origin Chef repository
![Page 65: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/65.jpg)
Developer uses Knife to push new code to the Chef Server
![Page 66: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/66.jpg)
Developer uses Knife to tell Chef-clients to update themselves
![Page 67: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/67.jpg)
Chef-client on Chef nodes contact the Chef Server
![Page 68: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/68.jpg)
Chef-client pulls latest code from the Chef Server
![Page 69: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/69.jpg)
Chef-client on the node updates the system
![Page 70: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/70.jpg)
Practical example
![Page 71: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/71.jpg)
Update authorized_keys
$ echo 'ssh-rsa dev4-public-key' >> !$
$ cat cookbooks/bootstrap/files/default/authorized_keys
![Page 72: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/72.jpg)
Committing and pushing$ git diff
git add .git commit -m 'adding new public key'git push
![Page 73: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/73.jpg)
Updating Chef Serverbundle exec knife cookbook upload bootstrap cap configure:all
or ssh [email protected]$ chef-client
![Page 74: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/74.jpg)
How Chef helped us?
![Page 75: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/75.jpg)
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
![Page 76: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/76.jpg)
Clear separation between servers
with roles: FrontendBackendApplicationMemcachedDatabaseother..
![Page 77: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/77.jpg)
Chef requirementsChef-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 RubyRuby 1.8.7, 1.9.1 or 1.9.2 with SSL bindings is required. RubyGemsVersion 1.3.7 or greater. On Ubuntu and Debian Rubygems should be installed from source Git?
![Page 78: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/78.jpg)
Parts I didn't cover
- Setting up and running chef-server / chef-client- Shef- Knife plugins- Chef + capistrano- All the rest Chef goodies
![Page 79: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/79.jpg)
Chef Alternatives
● Puppet● Sprinkle● Rubber● Sunzi
![Page 80: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/80.jpg)
Great resources
https://github.com/opscode/cookbookshttp://wiki.opscode.com/display/chef/Homehttp://railscasts.com/episodes/339-chef-solo-basicshttps://github.com/ctshryock/capistrano-chef
![Page 81: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/81.jpg)
Thank You
![Page 82: What is Chef and how we use it at tripsta](https://reader034.fdocuments.in/reader034/viewer/2022052618/554a5d3ab4c9054b328b50d0/html5/thumbnails/82.jpg)