Search code examples
chef-infraknifeberkshelf

knife and berkshelf difference?


knife and berkshelf are both used for uploading the cookbook. the berkshelf is taking care of "third party dependencies" as well feom berkfile or Metadata.rb. Is that the only difference or there is more to it?


Solution

  • In a loose sense, Berkshelf is a kind of "package manager" for Chef cookbooks.

    It is somewhat like what yum is to rpm, or what apt-get is to dpkg.

    As you pointed out, Berkshelf provides dependency management for a given Chef cookbook. It can not only pull external dependencies, but dependent cookbooks (and versions) from a given code (Git/Bitbucket) repository. And with larger Chef deployments, there is always the complication of managing multiple dependencies.

    Sometimes the dependencies are immediately obvious. Just to illustrate this, if I have a cookbook my_rabbitmq_server, with metadata.rb as:

    version '0.1.0'
    
    depends 'rabbitmq', '>= 5.7.0'
    

    I may be tempted to think that there is only 1 dependency, and I can easily resolve it with knife.

    However...

    The rabbitmq cookbook may depend on other cookbooks, which may depend on some others. This kind of nested dependency can result in having to pull many cookbooks (sometimes > 10). This can be done by knife, but it is time consuming and error prone.

    Another feature is that cookbooks uploaded with Berkshelf are frozen for that version (default behaviour). It will prevent the cookbook with same version from being uploaded again.

    If we refer to the above example, I would not be able to upload my_rabbitmq_server version 0.1.0 with Berkshelf after making some changes. So it kind of makes version bump necessary for any changes to cookbook code.

    If you haven't already gone through the official documentation, I would highly recommend you to do so.