What is Chef and how we use it at tripsta


Published on

Short intro what is Chef and how we used in our company: tripsta!

Published in: Technology, Self Improvement
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

What is Chef and how we use it at tripsta

  1. 1. What is Chef....and how we use it at
  2. 2. Who am I? Giedrius Rimkus LithuanianPHP Developer at tripsta Ruby enthusiast Basketball lover @giedriusr
  3. 3. Ill be talking about.. Sentiments Pain Solution
  4. 4. Back in 2009..
  5. 5. Infrastructure Application
  6. 6. Infrastructure Application
  7. 7. Infrastructure Application Application Database
  8. 8. Infrastructure Application Application Application Database
  9. 9. Infrastructure Application Application Application Application Database Application
  10. 10. Infrastructure Application Application Application Application Database Application API API LB LB
  11. 11. Complexity
  12. 12. Pain○ Long installation process○ Hard maintenance○ Scaling issues○ Constantly increased load and usage of resources (no load balancer)
  13. 13. Solution
  14. 14. CLUSTER
  15. 15. WTH IS CLUSTER?
  16. 16. What is a Cluster?Its a group of linked computers, workingtogether closely thus in many respects forminga single computer.
  17. 17. Cluster categoriesHigh-availability (HA) clustersHigh-availability clusters (also known as failover cluster) are implementedprimarily for the purpose of improving the availability of services that thecluster provides. Load-balancing clustersLoad-balancing is when multiple computers are linked together to sharecomputational workload or function as a single virtual computer. Logically,from the user side, they are multiple machines, but function as a singlevirtual machine. Compute clustersSomes times called as a “Grid computing”. Basically used for calculating hugestats, etc.
  18. 18. HOW TO BUILD IT?
  19. 19. OR
  20. 20. What is Chef? What problem does it solve?Chef is an open-source systems integrationframework built specifically for automatingthe cloud / system configuration. 
  21. 21. Chef typesChef Solo Chef client and Chef server Hosted Chef Private Chef
  22. 22. Chef Solo....is an open source standalone version of Chefthat runs locally on your node, detached froma Chef server.
  23. 23. Chef Client and Chef ServerChef-client connects to a Chef Server to be told what todo on the node.
  24. 24. Hosted ChefAs with Chef-Server, Chef-client connects to Hosted Chefto be told what to do on the local node.
  25. 25. Private Chef....is for Enterprises who want the power, flexibility,availability, and performance of Hosted Chef, but requirethat information never leave their private networks.
  26. 26. Why its an issue?Infrastructure changes all the time.Different operating systemsDifferent hardware from different vendors.
  27. 27. 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.
  28. 28. Some goodies I like about Chef"Manage your servers by writing code,not by running commands." Chef is idempotent Built on top of Ruby  
  29. 29. Chef Server Architecture
  30. 30. Architecture visualization
  31. 31. Basic structure of ChefEnvironmentsNodesCookbooksRecipesFiles / TemplatesAttributesData BagsSearch
  32. 32. 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?
  33. 33. Modeling yourinfrastructure
  34. 34. NodesA node is a host that runs the Chef client. Theprimary features of a node, from Chefs pointof view, are its attributes and its run list.Nodes are the thing that Recipes and Roles areapplied to.
  35. 35. RolesA role means grouping similar features ofsimilar nodes.
  36. 36. Run listA list of recipes that a node will run.
  37. 37. Configuring Nodes
  38. 38. CookbooksA cookbook is a collection of recipe, resourcedefinition, attribute, library, cookbook fileand template files that chef uses to configurea system. Cookbooks are typically groupedaround configuring a single package or service. The MySQL cookbook, for example, containsrecipes for both client and server.
  39. 39. RecipesRecipes are the files where you write yourresources (code).
  40. 40. Another examplechef/cookbooks/git/recipes/default.rbpackage "git-core"# apt-get install git-core# yum install git-core# etc..
  41. 41. Another exampledirectory "/home/new_folder" do mode 0755 owner "someuser" group "www" action :createend
  42. 42. MetadataCookbooks often rely on other cookbooks forpre-requisite functionality. In order for theserver to know which cookbooks to ship to aclient, a cookbook that depends on anotherone needs to express that dependencysomewhere. That "somewhere" is in cookbookmetadata.
  43. 43. ResourcesA resource is usually a cross platformabstraction of the thing youre configuring onthe host. Chefs resources are mostly just containers fordata, with some basic validation functionality.
  44. 44. ResourcesHave a typeHave a nameHave parametersTake action to put the resource in thedeclared state
  45. 45. Type
  46. 46. Name
  47. 47. Parameters
  48. 48. Action
  49. 49. ProvidersThe provider is the platform-specificimplementation of the thing a resourceabstracts. On Red Hat or CentOS - yumDebian and Ubuntu - apt package manager willbe used
  50. 50. SearchSearch is built by the Chef Server, and allowyou to query arbitrary data about yourinfrastructure
  51. 51. Data BagsData Bags store nested key–value data on thechef server. Data Bag data are searchable, andcan also be loaded directly by name in arecipe. Data Bags are global for your chef-server installation–you can think of them asattributes for your whole infrastructure.
  52. 52. EnvironmentsProvides a mechanism for managing differentarchitectural segmented spaces such asproduction, staging, development, andtesting, etc with one Chef setup.
  53. 53. Chef Workflow
  54. 54. Everyday Chef Workflow for developers
  55. 55. Developer makes changes to Chef recipes, roles, etc.
  56. 56. Developer pushes changes to origin Chef repository
  57. 57. Developer uses Knife to push new code to the Chef Server
  58. 58. Developer uses Knife to tell Chef-clients to update themselves
  59. 59. Chef-client on Chef nodes contact the Chef Server
  60. 60. Chef-client pulls latest code from the Chef Server
  61. 61. Chef-client on the node updates the system
  62. 62. Practical example
  63. 63. Update authorized_keys$ cat cookbooks/bootstrap/files/default/authorized_keys$ echo ssh-rsa dev4-public-key >> !$
  64. 64. Committing and pushing $ git diffgit add .git commit -m adding new public keygit push
  65. 65. Updating Chef Serverbundle exec knife cookbook upload bootstrapcap configure:allorssh root@$ chef-client
  66. 66. How Chef helped us?
  67. 67. We dont care that much aboutInfrastructure changes all the time Scalability, because..- adding new nodes is painless- its fast (takes minutes or hours, not days or weeks)- there is no need in buying more machines with everynew website
  68. 68. Clear separation between serverswith roles: FrontendBackendApplicationMemcachedDatabaseother..
  69. 69. 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 installedfrom source Git?
  70. 70. Parts I didnt cover- Setting up and running chef-server / chef-client- Shef- Knife plugins- Chef + capistrano- All the rest Chef goodies
  71. 71. Chef Alternatives● Puppet● Sprinkle● Rubber● Sunzi
  72. 72. Great resourceshttps://github.com/opscode/cookbookshttp://wiki.opscode.com/display/chef/Homehttp://railscasts.com/episodes/339-chef-solo-basicshttps://github.com/ctshryock/capistrano-chef
  73. 73. Thank You