$30 off During Our Annual Pro Sale. View Details »

Introduction to Application Automation with Habitat

Nathen Harvey
September 21, 2016

Introduction to Application Automation with Habitat

Habitat is a new approach to automation that focuses on the application instead of the infrastructure it runs on. With Habitat, the apps you build, deploy, and manage behave consistently in any runtime — bare metal, VMs, containers, and PaaS. You'll spend less time on the environment and more time building features.

This workshop will provide attendees with the knowledge of how to package and run applications with Habitat. At the end of this workshop attendees will understand Habitat's packaging technology, how to package an existing application with Habitat, the benefits of the Habitat studio, how the Habitat supervisor works to provides application focused automation, and how to run applications using Habitat.

This training was given at Surge Conference 2016

Nathen Harvey

September 21, 2016
Tweet

More Decks by Nathen Harvey

Other Decks in Technology

Transcript

  1. ©2016 Chef Software Inc. 1-1 Introduction to Application Automation Workshop

    Modern Applications
  2. ©2016 Chef Software Inc. 1-2 Modern Applications Source Code Repo

    Artifact Bare Metal Containers AMI VM Artifact Repo
  3. ©2016 Chef Software Inc. 1-3 Immutable Infrastructure

  4. ©2016 Chef Software Inc. 1-4 Immutable Infrastructure Applications

  5. ©2016 Chef Software Inc. 1-5 Dependencies!

  6. ©2016 Chef Software Inc. 1-6 Packaging and Deployment

  7. ©2016 Chef Software Inc. 1-7 Deployment Topology Leader Initializer Stand-alone

  8. ©2016 Chef Software Inc. 1-8 Isolation •  Running multiple Java

    applications •  Need to patch the JDK •  Patching the JDK for one application should not impact other applications
  9. ©2016 Chef Software Inc. 1-9 Immutability •  Verify the contents

    of the package match what you expect •  Build a .war and move it from one environment to the next. How do you know it's the same? •  Package doesn't change but exposes interface to be dynamically configured at runtime
  10. ©2016 Chef Software Inc. 1-10 API for configuration •  Allow

    for configuration or tuning •  Describe configurations and tunable parameters
  11. ©2016 Chef Software Inc. 1-11 Rebuild from Source •  Version

    control of all source code •  Change management •  Governance •  Auditing
  12. ©2016 Chef Software Inc. 1-12 Language Agnostic Packaging Packaging of

    the application should be independent of the application's language
  13. ©2016 Chef Software Inc. 1-13 Independence from runtime environments • 

    Isolate application from runtime environment •  Complexity increases without this isolation •  Runtime environments are evolving rapidly •  Building for a specific runtime leads to legacy •  Portability is key
  14. ©2016 Chef Software Inc. 1-14 Deployment Patterns •  Peer-based Scaling

    - independent of the immutable artifact •  Update strategies •  All at once •  Canary •  Deployment topologies •  Stand-alone •  Leader – Follower •  Initializer
  15. ©2016 Chef Software Inc. 1-15 Freedom to Focus •  Create

    features to drive the business and delight customers •  Bare metal, virtualization, cloud, PaaS? •  Defer choices about infrastructure until late in the development lifecycle
  16. ©2016 Chef Software Inc. 1-16 What would it look like

    if we built •  ... for choreography instead of orchestration? •  … for large, distributed systems that are topology aware? •  ... a way to run immutable systems with flexibility and ease •  ... a way to strip out hidden dependencies? •  ... a simplified toolchain?
  17. ©2016 Chef Software Inc. 1-17

  18. ©2016 Chef Software Inc. 1-18 Habitat Application automation that enables

    modern application teams to build, deploy, and manage any application in any environment - from traditional data-centers to containerized microservices.
  19. ©2016 Chef Software Inc. 1-19 Habitat’s Approach •  Applications run

    as distributed, fully automated, and capable autonomous actors •  Immutable applications, but flexible and easy to manage because automation travels with the application •  Bundles what your apps need to run and nothing else •  Embedded automation choreographs application cluster topology/behavior •  A network with no reliance on external services and no single-point-of-failure •  Provides continuous deployment without traditional Application Release Automation (ARA) tooling
  20. ©2016 Chef Software Inc. 1-20 Habitat’s Approach •  The solution

    is the same: •  For new and legacy applications •  No matter the application runtime environment
  21. ©2016 Chef Software Inc. 2-21 Environment Setup

  22. ©2016 Chef Software Inc. 2-22 Enough with the talky, talky!

    Let’s try out Habitat
  23. ©2016 Chef Software Inc. 2-23 Objectives •  Login to the

    remote workstation •  Set-up Habitat
  24. ©2016 Chef Software Inc. 2-24 Objective: Login to a remote

    workstation Lab: Remote Workstation
  25. ©2016 Chef Software Inc. 2-25 Find your IP Address https://goo.gl/6b9pgn

  26. ©2016 Chef Software Inc. 2-26 The authenticity of host '52.23.203.107

    (52.23.203.107)' can't be established. ECDSA key fingerprint is SHA256:HoR68T+W6kAwQv0ZC0qAMSiO4lVqpQQRwO6WnvPb2oY. Are you sure you want to continue connecting (yes/no)? $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation
  27. ©2016 Chef Software Inc. 2-27 The authenticity of host '52.23.203.107

    (52.23.203.107)' can't be established. ECDSA key fingerprint is SHA256:HoR68T+W6kAwQv0ZC0qAMSiO4lVqpQQRwO6WnvPb2oY. Are you sure you want to continue connecting (yes/no)? yes $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation
  28. ©2016 Chef Software Inc. 2-28 The authenticity of host '52.23.203.107

    (52.23.203.107)' can't be established. ECDSA key fingerprint is SHA256:HoR68T+W6kAwQv0ZC0qAMSiO4lVqpQQRwO6WnvPb2oY. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '52.23.203.107' (ECDSA) to the list of known hosts. chef@52.23.203.107's password: $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation
  29. ©2016 Chef Software Inc. 2-29 The authenticity of host '52.23.203.107

    (52.23.203.107)' can't be established. ECDSA key fingerprint is SHA256:HoR68T+W6kAwQv0ZC0qAMSiO4lVqpQQRwO6WnvPb2oY. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '52.23.203.107' (ECDSA) to the list of known hosts. chef@52.23.203.107's password: chef $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation
  30. ©2016 Chef Software Inc. 2-30 Objective: Lab: Install Habitat Install

    Habitat
  31. ©2016 Chef Software Inc. 2-31 Habitat.sh

  32. ©2016 Chef Software Inc. 2-32 Habitat.sh

  33. ©2016 Chef Software Inc. 2-33 % Total % Received %

    Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 301 0 301 0 0 1608 0 --:--:-- --:--:-- --:--:-- 1609 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 3225k 100 3225k 0 0 3566k 0 --:--:-- --:--:-- --:--:-- 3566k $ curl -L https://goo.gl/2ac5Qk -o hab-x86_64-linux.tar.gz Download Habitat
  34. ©2016 Chef Software Inc. 2-34 hab-0.9.3-20160916191534-x86_64-linux/ hab-0.9.3-20160916191534-x86_64-linux/hab $ tar xzvf

    hab-x86_64-linux.tar.gz Extract Habitat
  35. ©2016 Chef Software Inc. 2-35 $ sudo cp hab-0.9.3-20160916191534-x86_64-linux/hab /bin

    Put hab into the path
  36. ©2016 Chef Software Inc. 2-36 /usr/bin/hab $ which hab Verify

    the installation
  37. ©2016 Chef Software Inc. 2-37 hab 0.9.3/20160916191534 $ hab --version

    Verify the installation
  38. ©2016 Chef Software Inc. 2-38 Objective: Optional: GitHub Personal Access

    Token Generate a GitHub Personal Access Token
  39. ©2016 Chef Software Inc. 2-39 GitHub Settings

  40. ©2016 Chef Software Inc. 2-40 Personal Settings

  41. ©2016 Chef Software Inc. 2-41 Generate new token

  42. ©2016 Chef Software Inc. 2-42 Confirm password

  43. ©2016 Chef Software Inc. 2-43 Generate token

  44. ©2016 Chef Software Inc. 2-44 Copy token

  45. ©2016 Chef Software Inc. 2-45 Objective: Setup Habitat Complete the

    habitat setup
  46. ©2016 Chef Software Inc. 2-46 Set up a default origin

    Every package in Habitat belongs to an origin, which indicates the person or organization responsible for maintaining that package. Each origin also has a key used to cryptographically sign packages in that origin. Selecting a default origin tells package building operations such as 'hab pkg build' what key should be used to sign the packages produced. If you do not set a default origin now, you will have to tell package building commands each time what origin to use. For more information on origins and how they are used in building packages, please consult the docs at https://www.habitat.sh/docs/create-packages-build/ Set up a default origin? [Yes/no/quit] $ sudo hab setup Setup
  47. ©2016 Chef Software Inc. 2-47 Enter the name of your

    origin. If you plan to publish your packages publicly, we recommend that you select one that is not already in use on the Habitat build service found at https://app.habitat.sh/. Default origin name: [default: root] Setup
  48. ©2016 Chef Software Inc. 2-48 Enter the name of your

    origin. If you plan to publish your packages publicly, we recommend that you select one that is not already in use on the Habitat build service found at https://app.habitat.sh/. Default origin name: [default: root] firstnamelastname Setup
  49. ©2016 Chef Software Inc. 2-49 Create origin key pair It

    doesn't look like you have a signing key for the origin `firstnamelastname'. Without it, you won't be able to build new packages successfully. You can either create a new signing key now, or, if you are building packages for an origin that already exists, ask the owner to give you the signing key. For more information on the use of origin keys, please consult the documentation at https://www.habitat.sh/docs/concepts-keys/#origin-keys Create an origin key for `firstnamelastname'? [Yes/no/quit] Setup
  50. ©2016 Chef Software Inc. 2-50 Create an origin key for

    `firstnamelastname'? [Yes/no/quit] Yes Setup
  51. ©2016 Chef Software Inc. 2-51 GitHub Access Token While you

    can build and run Habitat packages without sharing them on the public depot, doing so allows you to collaborate with the Habitat community. In addition, it is how you can perform continuous deployment with Habitat. The depot uses GitHub authentication with an access token with the user:email scope (https://help.github.com/articles/creating-an-access-token-for-command-line-use/). If you would like to share your packages on the depot, please enter your GitHub access token. Otherwise, just enter No. For more information on sharing packages on the depot, please read the documentation at https://www.habitat.sh/docs/share-packages-overview/ Set up a default GitHub access token? [Yes/no/quit] Setup
  52. ©2016 Chef Software Inc. 2-52 Set up a default GitHub

    access token? [Yes/no/quit] Yes Setup
  53. ©2016 Chef Software Inc. 2-53 Enter your GitHub access token.

    GitHub access token: Setup
  54. ©2016 Chef Software Inc. 2-54 Enter your GitHub access token.

    GitHub access token: f10811c0cd7056ac510ce44ad79f9b141057b043 Setup
  55. ©2016 Chef Software Inc. 2-55 Analytics The `hab` command-line tool

    will optionally send anonymous usage data to Habitat's Google Analytics account. This is a strictly opt-in activity and no tracking will occur unless you respond affirmatively to the question below. We collect this data to help improve Habitat's user experience. For example, we would like to know the category of tasks users are performing, and which ones they are having trouble with (e.g. mistyping command line arguments). To see what kinds of data are sent and how they are anonymized, please read more about our analytics here: https://www.habitat.sh/docs/about-analytics/ Enable analytics? [Yes/no/quit] Setup
  56. ©2016 Chef Software Inc. 2-56 Enable analytics? [Yes/no/quit] Setup

  57. ©2016 Chef Software Inc. 2-57 » Opting in to analytics

    Ω Creating /hab/cache/analytics/OPTED_IN ★ Analytics opted in, thank you! CLI Setup Complete That's all for now. Thanks for using Habitat! Setup
  58. ©2016 Chef Software Inc. 2-58 Discussion What do you know

    about the remote workstation? Is a GitHub access token required? What is required to install Habitat on Mac OS? What is required to install Habitat on Windows?
  59. ©2016 Chef Software Inc. 3-59 Create a Plan My Tutorial

    Project
  60. ©2016 Chef Software Inc. 3-60 Objectives Describe the parts of

    a plan Build a Habitat artifact
  61. ©2016 Chef Software Inc. 3-61 My Tutorial Project A simple

    Node.js application Allows for exploration of many Habitat features Not overly complex
  62. ©2016 Chef Software Inc. 3-62 $ cd ~ Clone the

    project
  63. ©2016 Chef Software Inc. 3-63 Cloning into 'habitat-example-plans'... remote: Counting

    objects: 67, done. remote: Total 67 (delta 0), reused 0 (delta 0), pack-reused 67 Unpacking objects: 100% (67/67), done. $ git clone https://github.com/habitat-sh/habitat-example-plans Clone the project
  64. ©2016 Chef Software Inc. 3-64 $ cd ~/habitat-example-plans/mytutorialapp Clone the

    project
  65. ©2016 Chef Software Inc. 3-65 . ├── habitat │ └──

    plan.sh └── source ├── config │ └── config.json ├── package.json └── server.js 3 directories, 4 files $ tree Explore the files
  66. ©2016 Chef Software Inc. 3-66 $ cd ~/habitat-example-plans/mytutorialapp/habitat Update the

    plan
  67. ©2016 Chef Software Inc. 3-67 Choose an editor You'll need

    to choose an editor to edit files: •  emacs •  vim •  nano
  68. ©2016 Chef Software Inc. 3-68 Update the plan pkg_origin=firstnamelastname pkg_name=mytutorialapp

    pkg_version=0.2.0 pkg_maintainer="Your Name <you@example.com>" pkg_license=() pkg_source=https://github.com/habitat-sh/habitat-example-plans/tree/ master/mytutorialapp/source pkg_deps=(core/node) pkg_expose=(8080) ~/habitat-example-plans/mytutorialapp/habitat/plan.sh
  69. ©2016 Chef Software Inc. 3-69 Installing from source

  70. ©2016 Chef Software Inc. 3-70 Callbacks Shell functions executed when

    building artifacts: •  do_begin() •  do_download() •  do_verify() •  do_check() •  do_clean() •  do_unpack() •  do_prepare() •  do_build() •  do_install() •  do_strip() •  do_end()
  71. ©2016 Chef Software Inc. 3-71 Update the plan (continued) do_download()

    { return 0 } do_verify() { return 0 } do_unpack() { return 0 } ~/habitat-example-plans/mytutorialapp/habitat/plan.sh
  72. ©2016 Chef Software Inc. 3-72 Update the plan (continued) do_build()

    { # The mytutorialapp source code is in a relative directory, so you must copy the # contents of the source directory into your $HAB_CACHE_SRC_PATH/$pkg_dirname as this # is the same path that Habitat would use if you downloaded a tarball of the source code. cp -vr $PLAN_CONTEXT/../source/* $HAB_CACHE_SRC_PATH/$pkg_dirname # This installs both npm as well as the nconf module we listed as a # dependency in package.json. npm install } ~/habitat-example-plans/mytutorialapp/habitat/plan.sh
  73. ©2016 Chef Software Inc. 3-73 Update the plan (continued) do_install()

    { # Our source files were copied over to HAB_CACHE_SRC_PATH/$pkg_dirname in do_build(), # and now they need to be copied from that directory into the root directory of our package # through the use of the pkg_prefix variable. cp package.json ${pkg_prefix} cp server.js ${pkg_prefix} # Copy over the nconf module to the package that we installed in do_build(). mkdir -p ${pkg_prefix}/node_modules/ cp -vr node_modules/* ${pkg_prefix}/node_modules/ } ~/habitat-example-plans/mytutorialapp/habitat/plan.sh
  74. ©2016 Chef Software Inc. 3-74 Compare plans https://goo.gl/rKboZn

  75. ©2016 Chef Software Inc. 3-75 $ cd ~/habitat-example-plans/mytutorialapp/ Enter the

    studio
  76. ©2016 Chef Software Inc. 3-76 $ sudo hab studio enter

    Enter the studio
  77. ©2016 Chef Software Inc. 3-77 Habitat Studio The Habitat Studio

    is a clean, self-contained, minimal environment in which you can develop, build, and package software that is free from any upstream operating system distribution. All tools and dependencies included in the Studio are installed through Habitat packages, thus preventing any unwanted dependencies from being used by your package.
  78. ©2016 Chef Software Inc. 3-78 ∵ Missing package for core/hab-studio

    » Installing core/hab-studio ↓ Downloading core/hab-studio/0.9.3/20160916192516 2.87 MB / 2.87 MB / [========================================] 100.00 % 14.32 MB/ s ↓ Downloading core-20160810182414 public origin key 75 B / 75 B | [===============================================] 100.00 % 4.74 MB/ s ☑ Cached core-20160810182414 public origin key ✓ Installed core/hab-studio/0.9.3/20160916192516 ★ Install of core/hab-studio/0.9.3/20160916192516 complete with 1 new packages installed. hab-studio: Creating Studio at /hab/studios/home--chef--habitat-example-plans-- mytutorialapp (default) hab-studio: Importing firstnamelastname secret origin key $ sudo hab studio enter Enter the studio
  79. ©2016 Chef Software Inc. 3-79 : Loading /src/habitat/plan.sh mytutorialapp: Plan

    loaded … mytutorialapp: hab-plan-build cleanup mytutorialapp: mytutorialapp: Source Cache: /hab/cache/src/mytutorialapp-0.2.0 mytutorialapp: Installed Path: /hab/pkgs/nathenharvey-surge3/mytutorialapp/0.2.0/20160918001011 mytutorialapp: Artifact: /src/results/nathenharvey-surge3-mytutorialapp-0.2.0-20160918001011-x86_64- linux.hart mytutorialapp: Build Report: /src/results/last_build.env mytutorialapp: SHA256 Checksum: 5e9f4e2f2465cd6565ec3ac72e726bd65262f3a8f1d2b38f38637f2bbef19a4e mytutorialapp: Blake2b Checksum: abc9eca3d0c4743a89351d0b0aa690dedeffd0fa0b6f564816fc5fb719ce88da mytutorialapp: mytutorialapp: I love it when a plan.sh comes together. mytutorialapp: mytutorialapp: Build time: 0m7s $ build Build the artifact
  80. ©2016 Chef Software Inc. 3-80 Examine the artifact Source files:

    /hab/pkgs/YOUR_ORIGIN/mytutorialapp/0.2.0/BUILD Package: /src/results/YOUR_ORIGIN-mytutorialapp-0.2.0-BUILD- x86_64-linux.hart
  81. ©2016 Chef Software Inc. 3-81 Discussion What language are used

    to write plans? What are the different parts that make up a plan? What is the Habitat studio? Why build packages in the studio? Where can you find the artifacts generated by the build process?
  82. ©2016 Chef Software Inc. 4-82 Hooks They are what brings

    you back
  83. ©2016 Chef Software Inc. 4-83 Hooks Each plan can have

    a hooks subdirectory that specifies any of the hooks or asynchronous callbacks described in this section. Each hook is a bash script with a shebang defined at the top of the script to specify the interpreter to be used. •  file_updated •  health_check •  init •  reconfigure •  run
  84. ©2016 Chef Software Inc. 4-84 Launch the mytutorialapp Running the

    application requires: •  Linking the files to the proper location (init) •  Starting the application (run)
  85. ©2016 Chef Software Inc. 4-85 $ cd ~/habitat-example-plans/mytutorialapp/habitat Add an

    Initialization Hook
  86. ©2016 Chef Software Inc. 4-86 $ mkdir -p hooks Add

    an Initialization Hook
  87. ©2016 Chef Software Inc. 4-87 Add an Initialization Hook #!/bin/sh

    ln -sf {{pkg.path}}/package.json {{pkg.svc_var_path}} ln -sf {{pkg.path}}/server.js {{pkg.svc_var_path}} ln -sf {{pkg.path}}/node_modules {{pkg.svc_var_path}} ~/habitat-example-plans/mytutorialapp/habitat/hooks/init
  88. ©2016 Chef Software Inc. 4-88 Add a Run Hook #!/bin/sh

    cd {{pkg.svc_var_path}} exec npm start 2>&1 # `exec` makes it so the process that the Habitat supervisor uses is # `npm start`, rather than the run hook itself. `2>&1` makes it so both # standard output and standard error go to the standard output stream, # so all the logs from the application go to the same place. ~/habitat-example-plans/mytutorialapp/habitat/hooks/run
  89. ©2016 Chef Software Inc. 4-89 Discussion We created init and

    run hooks. What other hooks are available? What are the benefits of having a health_check hook defined? What language is used for hooks?
  90. ©2016 Chef Software Inc. 5-90 Add Configuration to the Project

    Immutable application, flexible configuration
  91. ©2016 Chef Software Inc. 5-91 Immutable Applications Knowing what’s out

    there is exactly what you deployed is pretty powerful. Small config changes add additional overhead on spinning new images/ containers. What about running an app in multiple environments, each with their own settings?
  92. ©2016 Chef Software Inc. 5-92 Add Configuration Habitat allows you

    to create templates of your application's native configuration files using Handlebars syntax. The mytutorialapp Node.js application has a configuration file: config.json
  93. ©2016 Chef Software Inc. 5-93 $ cd ~/habitat-example-plans/mytutorialapp/habitat Copy the

    config.json
  94. ©2016 Chef Software Inc. 5-94 $ mkdir –p config Copy

    the config.json
  95. ©2016 Chef Software Inc. 5-95 $ cp ../source/config/config.json config/ Copy

    the config.json
  96. ©2016 Chef Software Inc. 5-96 Update the configuration { "message":

    "{{cfg.message}}", "port": "{{cfg.port}}" } ~/habitat-example-plans/mytutorialapp/habitat/config/config.json
  97. ©2016 Chef Software Inc. 5-97 $ cd ~/habitat-example-plans/mytutorialapp/habitat Set default

    values
  98. ©2016 Chef Software Inc. 5-98 Set default values # Message

    of the Day message = "Hello, World!" # The port number that is listening for requests. port = 8080 ~/habitat-example-plans/mytutorialapp/habitat/template.toml
  99. ©2016 Chef Software Inc. 5-99 Handlebars Provide the power necessary

    to let you build semantic templates effectively with no frustration. Use block expressions to add basic logic to your template such as checking if a value exists or iterating through a list of items.
  100. ©2016 Chef Software Inc. 5-100 Changing the defaults? What prefix

    is used by all user-defined configuration settings? How are default values updated?
  101. ©2016 Chef Software Inc. 6-101 Run the Application In any

    operational environment
  102. ©2016 Chef Software Inc. 6-102 Run the Application Source Code

    Repo Artifact Bare Metal Containers AMI VM Artifact Repo
  103. ©2016 Chef Software Inc. 6-103 Application Run Times •  Natively

    on hardware •  Inside the habitat studio •  In a VM, cloud instance, etc. •  In a container •  Docker •  Application Container Image •  Mesos •  64-bit Linux distribution with a kernel version greater than 2.62
  104. ©2016 Chef Software Inc. 6-104 $ cd ~/habitat-example-plans/mytutorialapp Enter the

    Studio
  105. ©2016 Chef Software Inc. 6-105 hab-studio: Creating Studio at /hab/studios/home--chef--habitat-

    example-plans--mytutorialapp (default) hab-studio: Importing firstnamelastname secret origin key » Importing origin key from standard input ★ Imported secret origin key firstnamelastname-20160920041649. hab-studio: Entering Studio at /hab/studios/home--chef--habitat- example-plans--mytutorialapp (default) hab-studio: Exported: HAB_ORIGIN=firstnamelastname $ sudo hab studio enter Enter the Studio
  106. ©2016 Chef Software Inc. 6-106 mytutorialapp: hab-plan-build cleanup mytutorialapp: mytutorialapp:

    Source Cache: /hab/cache/src/mytutorialapp-0.2.0 mytutorialapp: Installed Path: /hab/pkgs/nathenharvey-surge3/mytutorialapp/ 0.2.0/20160918123432 mytutorialapp: Artifact: /src/results/nathenharvey-surge3- mytutorialapp-0.2.0-20160918123432-x86_64-linux.hart mytutorialapp: Build Report: /src/results/last_build.env mytutorialapp: SHA256 Checksum: 1bd6ef8873ee8040aac3838faea6304f2daae287b6c7dfaa394dad9e18a261f9 mytutorialapp: Blake2b Checksum: b467ee5a291e8c805562ffa44c6c774ab45cc466c76cb1f95b53bab3e271a1b7 mytutorialapp: mytutorialapp: I love it when a plan.sh comes together. mytutorialapp: mytutorialapp: Build time: 0m4s # build Build the package
  107. ©2016 Chef Software Inc. 6-107 ... mytutorialapp(SV): Starting mytutorialapp(O): mytutorialapp(O):

    > mytutorialapp@0.2.0 start /hab/svc/mytutorialapp/var mytutorialapp(O): > node server.js mytutorialapp(O): mytutorialapp(O): Running on http://0.0.0.0:8080 # hab start /src/results/YOURPACKAGE-x86_64-linux.hart Run the application
  108. ©2016 Chef Software Inc. 6-108 Open in a browser

  109. ©2016 Chef Software Inc. 6-109 Discussion Where are the packages

    stored? What format are the packages? What process runs the packages?
  110. ©2016 Chef Software Inc. 7-110 Inject Configuration Easily configure immutable

    artifacts
  111. ©2016 Chef Software Inc. 7-111 Immutable Infrastructure

  112. ©2016 Chef Software Inc. 7-112 Immutable Infrastructure Applications

  113. ©2016 Chef Software Inc. 7-113 Habitat Supervisor Habitat packages are

    run under the Habitat supervisor. At runtime, you can send configuration updates to the application.
  114. ©2016 Chef Software Inc. 7-114 Configuration Parameters The mytutorialapp was

    configured with two tunable parameters •  message •  port
  115. ©2016 Chef Software Inc. 7-115 API for Configuration Parameters • 

    The Habitat Supervisor provides a restful API •  This API will tell us what configuration parameters can be changed •  Open http://YOUR_IP_ADDRESS:9631/config
  116. ©2016 Chef Software Inc. 7-116 Default values The default values

    for these were set in the `default.toml` # Message of the Day message = "Hello, World!" # The port number that is listening for requests. port = 8080
  117. ©2016 Chef Software Inc. 7-117 Configuration Parameters These values are

    loaded in config/config.json by the application { "message": "{{cfg.message}}", "port": "{{cfg.port}}" }
  118. ©2016 Chef Software Inc. 7-118 hab-sup(MN): Starting firstnamelastname/mytutorialapp/0.2.0/20160920230450 hab-sup(TP): Child

    process will run as user=hab, group=hab hab-sup(GS): Supervisor 172.31.35.219: dd43b3b7-5f14-4970-ad92-a8eb31952495 hab-sup(GS): Census mytutorialapp.default: cee79b6d-9ee9-4f87-91aa-3d73cb2374da hab-sup(GS): Starting inbound gossip listener hab-sup(GS): Starting outbound gossip distributor hab-sup(GS): Starting gossip failure detector hab-sup(CN): Starting census health adjuster hab-sup(SC): Updated config.json hab-sup(TP): Restarting because the service config was updated via the census mytutorialapp(SV): Starting mytutorialapp(O): mytutorialapp(O): > mytutorialapp@0.2.0 start /hab/svc/mytutorialapp/var mytutorialapp(O): > node server.js mytutorialapp(O): mytutorialapp(O): Running on http://0.0.0.0:8080 # HAB_MYTUTORIALAPP='message = "Hello, Surge!"' hab start results/YOURPACKAGE-x86_64-linux.hart Override Configuration Parameters at Launch
  119. ©2016 Chef Software Inc. 7-119 Hello, Surge!

  120. ©2016 Chef Software Inc. 7-120 Check the configuration via the

    API
  121. ©2016 Chef Software Inc. 7-121 Questions You can pass configuration

    via environment variables to the Habitat Supervisor. What are the naming conventions for those environment variables? What values do you specify and in which format?
  122. ©2016 Chef Software Inc. 8-122 Run the Application Natively In

    any operational environment
  123. ©2016 Chef Software Inc. 8-123 Run the Application Source Code

    Repo Artifact Bare Metal Containers AMI VM Artifact Repo
  124. ©2016 Chef Software Inc. 8-124 Application Run Times •  Natively

    on hardware •  Inside the habitat studio •  In a VM, cloud instance, etc. •  In a container •  Docker •  Application Container Image •  Mesos •  64-bit Linux distribution with a kernel version greater than 2.62
  125. ©2016 Chef Software Inc. 8-126 $ cd ~/habitat-example-plans/mytutorialapp/results Install the

    package
  126. ©2016 Chef Software Inc. 8-127 → Using core/gcc-libs/5.2.0/20160612075020 → Using

    core/glibc/2.22/20160612063629 → Using core/linux-headers/4.3/20160612063537 → Using core/node/4.2.6/20160729200209 ✓ Installed firstnamelastname/mytutorialapp/0.2.0/20160920230450 ★ Install of firstnamelastname/mytutorialapp/0.2.0/20160920230450 complete with 1 new packages installed. sudo hab install YOURPACKAGE.hart Install the package
  127. ©2016 Chef Software Inc. 8-128 → Using core/gcc-libs/5.2.0/20160612075020 → Using

    core/glibc/2.22/20160612063629 → Using core/linux-headers/4.3/20160612063537 → Using core/node/4.2.6/20160729200209 ✓ Installed firstnamelastname/mytutorialapp/0.2.0/20160920230450 ★ Install of firstnamelastname/mytutorialapp/0.2.0/20160920230450 complete with 1 new packages installed. sudo hab start firstnamelastname/mytutorialapp Run the application
  128. ©2016 Chef Software Inc. 8-129 Open in a browser

  129. ©2016 Chef Software Inc. 8-130 Check the configuration via the

    API
  130. ©2016 Chef Software Inc. 8-131 hab-sup(MN): Starting firstnamelastname/mytutorialapp/0.2.0/20160920230450 hab-sup(TP): Child

    process will run as user=hab, group=hab hab-sup(GS): Supervisor 172.31.35.219: dd43b3b7-5f14-4970-ad92-a8eb31952495 hab-sup(GS): Census mytutorialapp.default: cee79b6d-9ee9-4f87-91aa-3d73cb2374da hab-sup(GS): Starting inbound gossip listener hab-sup(GS): Starting outbound gossip distributor hab-sup(GS): Starting gossip failure detector hab-sup(CN): Starting census health adjuster hab-sup(SC): Updated config.json hab-sup(TP): Restarting because the service config was updated via the census mytutorialapp(SV): Starting mytutorialapp(O): mytutorialapp(O): > mytutorialapp@0.2.0 start /hab/svc/mytutorialapp/var mytutorialapp(O): > node server.js mytutorialapp(O): mytutorialapp(O): Running on http://0.0.0.0:8080 $ HAB_MYTUTORIALAPP='message = "Hello, Surge!"’ sudo -E hab start firstnamelastname/mytutorialapp Override Configuration Parameters at Launch
  131. ©2016 Chef Software Inc. 8-132 Hello, Surge!

  132. ©2016 Chef Software Inc. 8-133 Check the configuration via the

    API
  133. ©2016 Chef Software Inc. 8-134 Discussion Where are the Habitat

    packages placed on disk?
  134. ©2016 Chef Software Inc. 8-135 Run the Application in Docker

    In any operational environment
  135. ©2016 Chef Software Inc. 8-136 Run the Application Source Code

    Repo Artifact Bare Metal Containers AMI VM Artifact Repo
  136. ©2016 Chef Software Inc. 8-137 Application Run Times •  Natively

    on hardware •  Inside the habitat studio •  In a VM, cloud instance, etc. •  In a container •  Docker •  Application Container Image •  Mesos •  64-bit Linux distribution with a kernel version greater than 2.62
  137. ©2016 Chef Software Inc. 8-138 Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor

    preset: disabled) Active: active (running) since Sun 2016-09-18 21:47:23 EDT; 1min 0s ago Docs: https://docs.docker.com Main PID: 26409 (dockerd) Memory: 18.9M CGroup: /system.slice/docker.service ├─26409 /usr/bin/dockerd └─26412 docker-containerd -l unix:///var/run/docker/ libcontainerd/docker-c... $ sudo service docker status Docker is Running
  138. ©2016 Chef Software Inc. 8-139 docker start/running, process 841 $

    sudo service docker status Docker is Running
  139. ©2016 Chef Software Inc. 8-140 cd ~/habitat-example-plans/mytutorialapp Export package as

    Docker container
  140. ©2016 Chef Software Inc. 8-141 $ sudo hab studio enter

    Export package as Docker container
  141. ©2016 Chef Software Inc. 8-142 hab-studio: Creating Studio at /tmp/hab-pkg-dockerize-xhCz/rootfs

    (baseimage) > Using local package for firstnamelastname/mytutorialapp > Using local package for core/gcc-libs/5.2.0/20160612075020 via firstnamelastname/mytutorialapp ... Step 8 : CMD start firstnamelastname/mytutorialapp ---> Running in 77d3b23fe1f1 ---> fedf3ae992bb Removing intermediate container 77d3b23fe1f1 Successfully built fedf3ae992bb # hab pkg export docker firstnamelastname/mytutorialapp Export package as Docker container
  142. ©2016 Chef Software Inc. 8-143 # exit Export package as

    Docker container
  143. ©2016 Chef Software Inc. 8-144 → Using core/gcc-libs/5.2.0/20160612075020 → Using

    core/glibc/2.22/20160612063629 → Using core/linux-headers/4.3/20160612063537 → Using core/node/4.2.6/20160729200209 ✓ Installed firstnamelastname/mytutorialapp/0.2.0/20160920230450 ★ Install of firstnamelastname/mytutorialapp/0.2.0/20160920230450 complete with 1 new packages installed. $ sudo docker run -it -p 8080:8080 -p 9631:9631 firstnamelastname/mytutorialapp Run the Docker container
  144. ©2016 Chef Software Inc. 8-145 Open in a browser

  145. ©2016 Chef Software Inc. 8-146 Check the configuration via the

    API
  146. ©2016 Chef Software Inc. 8-147 hab-sup(MN): Starting firstnamelastname/mytutorialapp hab-sup(TP): Child

    process will run as user=hab, group=hab hab-sup(GS): Supervisor 172.17.0.2: 117c3b88-1dcb-469c-8792-04a7b14804f4 hab-sup(GS): Census mytutorialapp.default: 77facd9c-ca73-4ed1-a9e8-d4fd5b47c883 hab-sup(GS): Starting inbound gossip listener hab-sup(GS): Starting outbound gossip distributor hab-sup(GS): Starting gossip failure detector hab-sup(CN): Starting census health adjuster hab-sup(SC): Updated config.json hab-sup(TP): Restarting because the service config was updated via the census mytutorialapp(SV): Starting mytutorialapp(O): mytutorialapp(O): > mytutorialapp@0.2.0 start /hab/svc/mytutorialapp/var mytutorialapp(O): > node server.js mytutorialapp(O): mytutorialapp(O): Running on http://0.0.0.0:8080 $ sudo docker run -e HAB_MYTUTORIALAPP='message = "Hello, Surge!"' -it -p 8080:8080 -p 9631:9631 firstnamelastname/mytutorialapp Override Configuration Parameters at Launch
  147. ©2016 Chef Software Inc. 8-148 Hello, Surge!

  148. ©2016 Chef Software Inc. 8-149 Check the configuration via the

    API
  149. ©2016 Chef Software Inc. 9-150 Discussion What happened before the

    package export began? What other export formats are available? What other export formats would you like to see? Where might you run this Docker container?
  150. None
  151. Our Vision the most enduring and transformative companies use Chef

    to become fast, efficient, and innovative software driven organizations
  152. People Products Companies

  153. None
  154. Build Deploy Manage

  155. None
  156. Application Automation

  157. The automation travels with the application

  158. None
  159. Starts with a plan

  160. ©2016 Chef Software Inc. Simple, native, and declaritive pkg_name=redis pkg_origin=core

    pkg_version=3.0.7 pkg_license=('BSD') pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>" pkg_source=http://download.redis.io/releases/${pkg_name}-${pkg_version}.tar.gz pkg_shasum=b2a791c4ea3bb7268795c45c6321ea5abcc24457178373e6a6e3be6372737f23 pkg_bin_dirs=(bin) pkg_build_deps=(core/make core/gcc) pkg_deps=(core/glibc) pkg_svc_run="bin/redis-server $pkg_svc_config_path/redis.config" pkg_expose=(6379) do_build() { make } plan.sh Low abstraction Complete dependencies Declare services Simple functions
  161. Clean room environment Safe by default Installs dependences Built in

    a studio
  162. Central location Publicly hosted Lightweight views Stored in a depot

  163. Easy pattern Shortcuts Increasing sepcificity Installed by hab

  164. Binaries and Config Metadata Side-by-side Packages on disk

  165. Docker ACI Mesosphere Post-process packages

  166. Run on any 64-bit Linux Easily support proprietary software

  167. Installs automatically Keeps things running Manages configuration Supervisor runs services

  168. Print config options 12-Factor style Externally enforced Environment configuration

  169. More flexible than environment Universal location Externally enforced File configuration

  170. Supervisors form a ring Peers Service Groups Gossip Availability increases

    with scale
  171. Supervisors support topologies Dynamic configruation Service group level Uses the

    ring
  172. Supervisors provide update strategies Topology aware Tracks views in the

    depot Ideal for Continuous Delivery
  173. Supervisors provide a REST API External Actors Health and Status

    Supervisor Debugging
  174. Automation travels with the application Existing & Cloud Native Software

    Application Automation
  175. Habitat: Automation that travels with the app •  Ease the

    burden of managing microservice apps and bring benefits of apps architected for microservices to legacy applications – Gain consistent management of new and legacy applications across lifecycle – Provides application portability for new and legacy apps – Autonomous nodes self-manage runtime state of application based upon policy you define – APIs expose application behaviors as data for better management •  Works in tandem with infrastructure automation •  Makes applications running on containers, PaaS, virtual machines, bare metal, … better
  176. It’s all open source Apache License

  177. Much more to do •  Automated, public build service • 

    More topologies •  More update strategies •  More plans •  More package export formats
  178. https://www.habitat.sh/community/

  179. None
  180. None
  181. None