Share
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
Transcript
181 slides
-
©2016 Chef Software Inc. 1-1 Introduction to Application Automation Workshop
Modern Applications -
©2016 Chef Software Inc. 1-2 Modern Applications Source Code Repo
Artifact Bare Metal Containers AMI VM Artifact Repo -
©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 -
©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 -
©2016 Chef Software Inc. 1-10 API for configuration • Allow
for configuration or tuning • Describe configurations and tunable parameters -
©2016 Chef Software Inc. 1-11 Rebuild from Source • Version
control of all source code • Change management • Governance • Auditing -
©2016 Chef Software Inc. 1-12 Language Agnostic Packaging Packaging of
the application should be independent of the application's language -
©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 -
©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 -
©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 -
©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? -
©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. -
©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 -
©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 -
©2016 Chef Software Inc. 2-22 Enough with the talky, talky!
Let’s try out Habitat -
©2016 Chef Software Inc. 2-23 Objectives • Login to the
remote workstation • Set-up Habitat -
©2016 Chef Software Inc. 2-24 Objective: Login to a remote
workstation Lab: Remote Workstation -
©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 -
©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 -
©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 -
©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 -
©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 -
©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 -
©2016 Chef Software Inc. 2-35 $ sudo cp hab-0.9.3-20160916191534-x86_64-linux/hab /bin
Put hab into the path -
©2016 Chef Software Inc. 2-36 /usr/bin/hab $ which hab Verify
the installation -
©2016 Chef Software Inc. 2-37 hab 0.9.3/20160916191534 $ hab --version
Verify the installation -
©2016 Chef Software Inc. 2-38 Objective: Optional: GitHub Personal Access
Token Generate a GitHub Personal Access Token -
©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 -
©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 -
©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 -
©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 -
©2016 Chef Software Inc. 2-50 Create an origin key for
`firstnamelastname'? [Yes/no/quit] Yes Setup -
©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 -
©2016 Chef Software Inc. 2-52 Set up a default GitHub
access token? [Yes/no/quit] Yes Setup -
©2016 Chef Software Inc. 2-53 Enter your GitHub access token.
GitHub access token: Setup -
©2016 Chef Software Inc. 2-54 Enter your GitHub access token.
GitHub access token: f10811c0cd7056ac510ce44ad79f9b141057b043 Setup -
©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 -
©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 -
©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? -
©2016 Chef Software Inc. 3-60 Objectives Describe the parts of
a plan Build a Habitat artifact -
©2016 Chef Software Inc. 3-61 My Tutorial Project A simple
Node.js application Allows for exploration of many Habitat features Not overly complex -
©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 -
©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 -
©2016 Chef Software Inc. 3-67 Choose an editor You'll need
to choose an editor to edit files: • emacs • vim • nano -
©2016 Chef Software Inc. 3-68 Update the plan pkg_origin=firstnamelastname pkg_name=mytutorialapp
pkg_version=0.2.0 pkg_maintainer="Your Name <[email protected]>" 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 -
©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() -
©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 -
©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 -
©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 -
©2016 Chef Software Inc. 3-76 $ sudo hab studio enter
Enter the studio -
©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. -
©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 -
©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 -
©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 -
©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? -
©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 -
©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) -
©2016 Chef Software Inc. 4-86 $ mkdir -p hooks Add
an Initialization Hook -
©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 -
©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 -
©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? -
©2016 Chef Software Inc. 5-90 Add Configuration to the Project
Immutable application, flexible configuration -
©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? -
©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 -
©2016 Chef Software Inc. 5-94 $ mkdir –p config Copy
the config.json -
©2016 Chef Software Inc. 5-96 Update the configuration { "message":
"{{cfg.message}}", "port": "{{cfg.port}}" } ~/habitat-example-plans/mytutorialapp/habitat/config/config.json -
©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 -
©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. -
©2016 Chef Software Inc. 5-100 Changing the defaults? What prefix
is used by all user-defined configuration settings? How are default values updated? -
©2016 Chef Software Inc. 6-101 Run the Application In any
operational environment -
©2016 Chef Software Inc. 6-102 Run the Application Source Code
Repo Artifact Bare Metal Containers AMI VM Artifact Repo -
©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 -
©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 -
©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 -
©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 -
©2016 Chef Software Inc. 6-109 Discussion Where are the packages
stored? What format are the packages? What process runs the packages? -
©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. -
©2016 Chef Software Inc. 7-114 Configuration Parameters The mytutorialapp was
configured with two tunable parameters • message • port -
©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 -
©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 -
©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}}" } -
©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 -
©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? -
©2016 Chef Software Inc. 8-122 Run the Application Natively In
any operational environment -
©2016 Chef Software Inc. 8-123 Run the Application Source Code
Repo Artifact Bare Metal Containers AMI VM Artifact Repo -
©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 -
©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 -
©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 -
©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 -
©2016 Chef Software Inc. 8-134 Discussion Where are the Habitat
packages placed on disk? -
©2016 Chef Software Inc. 8-135 Run the Application in Docker
In any operational environment -
©2016 Chef Software Inc. 8-136 Run the Application Source Code
Repo Artifact Bare Metal Containers AMI VM Artifact Repo -
©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 -
©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 -
©2016 Chef Software Inc. 8-139 docker start/running, process 841 $
sudo service docker status Docker is Running -
©2016 Chef Software Inc. 8-141 $ sudo hab studio enter
Export package as Docker container -
©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 -
©2016 Chef Software Inc. 8-143 # exit Export package as
Docker container -
©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 -
©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 -
©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? -
Our Vision the most enduring and transformative companies use Chef
to become fast, efficient, and innovative software driven organizations -
©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 <[email protected]>" 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 -
Supervisors provide update strategies Topology aware Tracks views in the
depot Ideal for Continuous Delivery -
Supervisors provide a REST API External Actors Health and Status
Supervisor Debugging -
Automation travels with the application Existing & Cloud Native Software
Application Automation -
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 -
Much more to do • Automated, public build service •
More topologies • More update strategies • More plans • More package export formats