Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

©2016 Chef Software Inc. 1-2 Modern Applications Source Code Repo Artifact Bare Metal Containers AMI VM Artifact Repo

Slide 3

Slide 3 text

©2016 Chef Software Inc. 1-3 Immutable Infrastructure

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

©2016 Chef Software Inc. 1-5 Dependencies!

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

©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

Slide 9

Slide 9 text

©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

Slide 10

Slide 10 text

©2016 Chef Software Inc. 1-10 API for configuration •  Allow for configuration or tuning •  Describe configurations and tunable parameters

Slide 11

Slide 11 text

©2016 Chef Software Inc. 1-11 Rebuild from Source •  Version control of all source code •  Change management •  Governance •  Auditing

Slide 12

Slide 12 text

©2016 Chef Software Inc. 1-12 Language Agnostic Packaging Packaging of the application should be independent of the application's language

Slide 13

Slide 13 text

©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

Slide 14

Slide 14 text

©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

Slide 15

Slide 15 text

©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

Slide 16

Slide 16 text

©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?

Slide 17

Slide 17 text

©2016 Chef Software Inc. 1-17

Slide 18

Slide 18 text

©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.

Slide 19

Slide 19 text

©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

Slide 20

Slide 20 text

©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

Slide 21

Slide 21 text

©2016 Chef Software Inc. 2-21 Environment Setup

Slide 22

Slide 22 text

©2016 Chef Software Inc. 2-22 Enough with the talky, talky! Let’s try out Habitat

Slide 23

Slide 23 text

©2016 Chef Software Inc. 2-23 Objectives •  Login to the remote workstation •  Set-up Habitat

Slide 24

Slide 24 text

©2016 Chef Software Inc. 2-24 Objective: Login to a remote workstation Lab: Remote Workstation

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

©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

Slide 27

Slide 27 text

©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

Slide 28

Slide 28 text

©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. [email protected]'s password: $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation

Slide 29

Slide 29 text

©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. [email protected]'s password: chef $ ssh chef@YOUR_IP_ADDRESS Login to your remote workstation

Slide 30

Slide 30 text

©2016 Chef Software Inc. 2-30 Objective: Lab: Install Habitat Install Habitat

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

©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

Slide 34

Slide 34 text

©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

Slide 35

Slide 35 text

©2016 Chef Software Inc. 2-35 $ sudo cp hab-0.9.3-20160916191534-x86_64-linux/hab /bin Put hab into the path

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

©2016 Chef Software Inc. 2-38 Objective: Optional: GitHub Personal Access Token Generate a GitHub Personal Access Token

Slide 39

Slide 39 text

©2016 Chef Software Inc. 2-39 GitHub Settings

Slide 40

Slide 40 text

©2016 Chef Software Inc. 2-40 Personal Settings

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

©2016 Chef Software Inc. 2-42 Confirm password

Slide 43

Slide 43 text

©2016 Chef Software Inc. 2-43 Generate token

Slide 44

Slide 44 text

©2016 Chef Software Inc. 2-44 Copy token

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

©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

Slide 47

Slide 47 text

©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

Slide 48

Slide 48 text

©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

Slide 49

Slide 49 text

©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

Slide 50

Slide 50 text

©2016 Chef Software Inc. 2-50 Create an origin key for `firstnamelastname'? [Yes/no/quit] Yes Setup

Slide 51

Slide 51 text

©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

Slide 52

Slide 52 text

©2016 Chef Software Inc. 2-52 Set up a default GitHub access token? [Yes/no/quit] Yes Setup

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

©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

Slide 56

Slide 56 text

©2016 Chef Software Inc. 2-56 Enable analytics? [Yes/no/quit] Setup

Slide 57

Slide 57 text

©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

Slide 58

Slide 58 text

©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?

Slide 59

Slide 59 text

©2016 Chef Software Inc. 3-59 Create a Plan My Tutorial Project

Slide 60

Slide 60 text

©2016 Chef Software Inc. 3-60 Objectives Describe the parts of a plan Build a Habitat artifact

Slide 61

Slide 61 text

©2016 Chef Software Inc. 3-61 My Tutorial Project A simple Node.js application Allows for exploration of many Habitat features Not overly complex

Slide 62

Slide 62 text

©2016 Chef Software Inc. 3-62 $ cd ~ Clone the project

Slide 63

Slide 63 text

©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

Slide 64

Slide 64 text

©2016 Chef Software Inc. 3-64 $ cd ~/habitat-example-plans/mytutorialapp Clone the project

Slide 65

Slide 65 text

©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

Slide 66

Slide 66 text

©2016 Chef Software Inc. 3-66 $ cd ~/habitat-example-plans/mytutorialapp/habitat Update the plan

Slide 67

Slide 67 text

©2016 Chef Software Inc. 3-67 Choose an editor You'll need to choose an editor to edit files: •  emacs •  vim •  nano

Slide 68

Slide 68 text

©2016 Chef Software Inc. 3-68 Update the plan pkg_origin=firstnamelastname pkg_name=mytutorialapp pkg_version=0.2.0 pkg_maintainer="Your Name " 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

Slide 69

Slide 69 text

©2016 Chef Software Inc. 3-69 Installing from source

Slide 70

Slide 70 text

©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()

Slide 71

Slide 71 text

©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

Slide 72

Slide 72 text

©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

Slide 73

Slide 73 text

©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

Slide 74

Slide 74 text

©2016 Chef Software Inc. 3-74 Compare plans https://goo.gl/rKboZn

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

©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.

Slide 78

Slide 78 text

©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

Slide 79

Slide 79 text

©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

Slide 80

Slide 80 text

©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

Slide 81

Slide 81 text

©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?

Slide 82

Slide 82 text

©2016 Chef Software Inc. 4-82 Hooks They are what brings you back

Slide 83

Slide 83 text

©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

Slide 84

Slide 84 text

©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)

Slide 85

Slide 85 text

©2016 Chef Software Inc. 4-85 $ cd ~/habitat-example-plans/mytutorialapp/habitat Add an Initialization Hook

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

©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

Slide 88

Slide 88 text

©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

Slide 89

Slide 89 text

©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?

Slide 90

Slide 90 text

©2016 Chef Software Inc. 5-90 Add Configuration to the Project Immutable application, flexible configuration

Slide 91

Slide 91 text

©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?

Slide 92

Slide 92 text

©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

Slide 93

Slide 93 text

©2016 Chef Software Inc. 5-93 $ cd ~/habitat-example-plans/mytutorialapp/habitat Copy the config.json

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

©2016 Chef Software Inc. 5-96 Update the configuration { "message": "{{cfg.message}}", "port": "{{cfg.port}}" } ~/habitat-example-plans/mytutorialapp/habitat/config/config.json

Slide 97

Slide 97 text

©2016 Chef Software Inc. 5-97 $ cd ~/habitat-example-plans/mytutorialapp/habitat Set default values

Slide 98

Slide 98 text

©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

Slide 99

Slide 99 text

©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.

Slide 100

Slide 100 text

©2016 Chef Software Inc. 5-100 Changing the defaults? What prefix is used by all user-defined configuration settings? How are default values updated?

Slide 101

Slide 101 text

©2016 Chef Software Inc. 6-101 Run the Application In any operational environment

Slide 102

Slide 102 text

©2016 Chef Software Inc. 6-102 Run the Application Source Code Repo Artifact Bare Metal Containers AMI VM Artifact Repo

Slide 103

Slide 103 text

©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

Slide 104

Slide 104 text

©2016 Chef Software Inc. 6-104 $ cd ~/habitat-example-plans/mytutorialapp Enter the Studio

Slide 105

Slide 105 text

©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

Slide 106

Slide 106 text

©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

Slide 107

Slide 107 text

©2016 Chef Software Inc. 6-107 ... mytutorialapp(SV): Starting mytutorialapp(O): mytutorialapp(O): > [email protected] 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

Slide 108

Slide 108 text

©2016 Chef Software Inc. 6-108 Open in a browser

Slide 109

Slide 109 text

©2016 Chef Software Inc. 6-109 Discussion Where are the packages stored? What format are the packages? What process runs the packages?

Slide 110

Slide 110 text

©2016 Chef Software Inc. 7-110 Inject Configuration Easily configure immutable artifacts

Slide 111

Slide 111 text

©2016 Chef Software Inc. 7-111 Immutable Infrastructure

Slide 112

Slide 112 text

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

Slide 113

Slide 113 text

©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.

Slide 114

Slide 114 text

©2016 Chef Software Inc. 7-114 Configuration Parameters The mytutorialapp was configured with two tunable parameters •  message •  port

Slide 115

Slide 115 text

©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

Slide 116

Slide 116 text

©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

Slide 117

Slide 117 text

©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}}" }

Slide 118

Slide 118 text

©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): > [email protected] 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

Slide 119

Slide 119 text

©2016 Chef Software Inc. 7-119 Hello, Surge!

Slide 120

Slide 120 text

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

Slide 121

Slide 121 text

©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?

Slide 122

Slide 122 text

©2016 Chef Software Inc. 8-122 Run the Application Natively In any operational environment

Slide 123

Slide 123 text

©2016 Chef Software Inc. 8-123 Run the Application Source Code Repo Artifact Bare Metal Containers AMI VM Artifact Repo

Slide 124

Slide 124 text

©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

Slide 125

Slide 125 text

©2016 Chef Software Inc. 8-126 $ cd ~/habitat-example-plans/mytutorialapp/results Install the package

Slide 126

Slide 126 text

©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

Slide 127

Slide 127 text

©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

Slide 128

Slide 128 text

©2016 Chef Software Inc. 8-129 Open in a browser

Slide 129

Slide 129 text

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

Slide 130

Slide 130 text

©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): > [email protected] 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

Slide 131

Slide 131 text

©2016 Chef Software Inc. 8-132 Hello, Surge!

Slide 132

Slide 132 text

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

Slide 133

Slide 133 text

©2016 Chef Software Inc. 8-134 Discussion Where are the Habitat packages placed on disk?

Slide 134

Slide 134 text

©2016 Chef Software Inc. 8-135 Run the Application in Docker In any operational environment

Slide 135

Slide 135 text

©2016 Chef Software Inc. 8-136 Run the Application Source Code Repo Artifact Bare Metal Containers AMI VM Artifact Repo

Slide 136

Slide 136 text

©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

Slide 137

Slide 137 text

©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

Slide 138

Slide 138 text

©2016 Chef Software Inc. 8-139 docker start/running, process 841 $ sudo service docker status Docker is Running

Slide 139

Slide 139 text

©2016 Chef Software Inc. 8-140 cd ~/habitat-example-plans/mytutorialapp Export package as Docker container

Slide 140

Slide 140 text

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

Slide 141

Slide 141 text

©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

Slide 142

Slide 142 text

©2016 Chef Software Inc. 8-143 # exit Export package as Docker container

Slide 143

Slide 143 text

©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

Slide 144

Slide 144 text

©2016 Chef Software Inc. 8-145 Open in a browser

Slide 145

Slide 145 text

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

Slide 146

Slide 146 text

©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): > [email protected] 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

Slide 147

Slide 147 text

©2016 Chef Software Inc. 8-148 Hello, Surge!

Slide 148

Slide 148 text

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

Slide 149

Slide 149 text

©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?

Slide 150

Slide 150 text

No content

Slide 151

Slide 151 text

Our Vision the most enduring and transformative companies use Chef to become fast, efficient, and innovative software driven organizations

Slide 152

Slide 152 text

People Products Companies

Slide 153

Slide 153 text

No content

Slide 154

Slide 154 text

Build Deploy Manage

Slide 155

Slide 155 text

No content

Slide 156

Slide 156 text

Application Automation

Slide 157

Slide 157 text

The automation travels with the application

Slide 158

Slide 158 text

No content

Slide 159

Slide 159 text

Starts with a plan

Slide 160

Slide 160 text

©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 " 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

Slide 161

Slide 161 text

Clean room environment Safe by default Installs dependences Built in a studio

Slide 162

Slide 162 text

Central location Publicly hosted Lightweight views Stored in a depot

Slide 163

Slide 163 text

Easy pattern Shortcuts Increasing sepcificity Installed by hab

Slide 164

Slide 164 text

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

Slide 165

Slide 165 text

Docker ACI Mesosphere Post-process packages

Slide 166

Slide 166 text

Run on any 64-bit Linux Easily support proprietary software

Slide 167

Slide 167 text

Installs automatically Keeps things running Manages configuration Supervisor runs services

Slide 168

Slide 168 text

Print config options 12-Factor style Externally enforced Environment configuration

Slide 169

Slide 169 text

More flexible than environment Universal location Externally enforced File configuration

Slide 170

Slide 170 text

Supervisors form a ring Peers Service Groups Gossip Availability increases with scale

Slide 171

Slide 171 text

Supervisors support topologies Dynamic configruation Service group level Uses the ring

Slide 172

Slide 172 text

Supervisors provide update strategies Topology aware Tracks views in the depot Ideal for Continuous Delivery

Slide 173

Slide 173 text

Supervisors provide a REST API External Actors Health and Status Supervisor Debugging

Slide 174

Slide 174 text

Automation travels with the application Existing & Cloud Native Software Application Automation

Slide 175

Slide 175 text

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

Slide 176

Slide 176 text

It’s all open source Apache License

Slide 177

Slide 177 text

Much more to do •  Automated, public build service •  More topologies •  More update strategies •  More plans •  More package export formats

Slide 178

Slide 178 text

https://www.habitat.sh/community/

Slide 179

Slide 179 text

No content

Slide 180

Slide 180 text

No content

Slide 181

Slide 181 text

No content