Application Automation &
Containerization With Habitat
Nathen Harvey | @nathenharvey
You will need a laptop with an SSH client.
Please sit on the left J
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
We Run Infrastructure
To Run Applications
That the Business Requires
Monolith Serverless
Microservices
Application
Application
Services
Few Large Artifacts Thousands of
Small Artifacts
Slide 11
Slide 11 text
Application Services
What Developers Need
Application Runtimes
Slide 12
Slide 12 text
Application Services
What Developers Need Want
Application Runtimes
Slide 13
Slide 13 text
https://twitter.com/codinghorror/status/347070841059692545
What Developers Need Want Build
Slide 14
Slide 14 text
Heterogeneity is the #1 stumbling block
to velocity.
Sprawl of management tools is the
biggest challenge facing modern IT
teams.
Current approaches start upside-down:
with the OS and not the app.
The core of the problem: application management
Habitat is used to build, deploy, and
manage applications…
Slide 18
Slide 18 text
…in any environment
from traditional datacenters
to containerized microservices
Slide 19
Slide 19 text
National Parks
• National Parks Application
Java Application running in Tomcat
MongoDB
Slide 20
Slide 20 text
No content
Slide 21
Slide 21 text
Modern Applications
Source
Code
Repo
Slide 22
Slide 22 text
Modern Applications
Source
Code
Repo
Artifact
Slide 23
Slide 23 text
Modern Applications
Source
Code
Repo
Artifact
Artifact
Repo
Slide 24
Slide 24 text
Modern Applications
Source
Code
Repo
Artifact
Bare Metal
Container
Cloud Instance
VM
Artifact
Repo
Slide 25
Slide 25 text
Modern Applications
Source
Code
Repo
Artifact
Bare Metal
Container
Cloud Instance
VM
Artifact
Repo
Slide 26
Slide 26 text
Modern Applications
Slide 27
Slide 27 text
Access the Learning Environment
Find your workstation’s IP address
Login to your workstation
Login to your workstation in a second window
User: chef
Password: devopsdays
Port: 443
Never do this at home!
• We are about disable some MongoDB security
Slide 51
Slide 51 text
Manages configuration
Installs automatically
Keeps things running
Supervisor runs services
Slide 52
Slide 52 text
$
Change the configuration for MongoDB
sudo hab config apply --peer 127.0.0.1 mongodb.default \
1 mongodb.toml
Slide 53
Slide 53 text
Applying Configuration
sudo hab config apply --peer 127.0.0.1 mongodb.default 1 mongodb.toml
• peer - hostname or IP address of a running supervisor
• mongodb.default - the service group
• 1 - the incarnation of this configuration
• mongodb.toml - the file with the new configuration
Slide 54
Slide 54 text
$
Change the configuration for MongoDB
∵ Missing package for core/hab-butterfly/0.31.0
» Installing core/hab-butterfly/0.31.0
↓ Downloading core/hab-butterfly/0.31.0/20170907235928
1.18 MB / 1.18 MB \ [===============================] 100.00 % 84.75 MB/s
☛ Verifying core/hab-butterfly/0.31.0/20170907235928
...
★ Install of core/hab-butterfly/0.31.0/20170907235928 complete with 1 new packages installed.
» Applying configuration for mongodb.default incarnation 1
Ω Creating service configuration
✓ Verified this configuration is valid TOML
↑ Applying to peer 127.0.0.1:9638
★ Applied configuration
sudo hab config apply --peer 127.0.0.1 mongodb.default \
1 mongodb.toml
Slide 55
Slide 55 text
$
Meanwhile, in the supervisor output
mongodb.default(CF): Updated mongod.conf
12a29a9de79166f30aa87640bc4ba4a88b6dc4d4641cf0d6ed00e179229d576f
mongodb.default(SR): Configuration recompiled
Slide 56
Slide 56 text
$
Meanwhile, in the supervisor output
national-parks.default(SR): Initializing
national-parks.default hook[init]:(HK): Seeding Mongo Collection
national-parks.default hook[init]:(HK): $MONGOIMPORT_OPTS=--host=172.31.26.105
--port=27017
national-parks.default hook[init]:(HK): 2017-09-06T19:27:08.177+0000
connected to: 172.31.26.105:27017
national-parks.default hook[init]:(HK): 2017-09-06T19:27:08.177+0000
dropping: demo.nationalparks
national-parks.default hook[init]:(HK): 2017-09-06T19:27:08.199+0000 imported
359 documents
national-parks.default(SV): Starting service as user=root, group=root
national-parks.default(O): Starting Apache Tomcat
Slide 57
Slide 57 text
$
Meanwhile, in the supervisor output
national-parks.default(O): 06-Sep-2017 19:27:23.424 INFO [localhost-startStop-1]
org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web
application directory /hab/pkgs/core/tomcat8/8.5.9/20170215223900/tc/webapps/
ROOT has finished in 8 ms
national-parks.default(O): 06-Sep-2017 19:27:23.428 INFO [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-
nio-8080]
national-parks.default(O): 06-Sep-2017 19:27:23.432 INFO [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
national-parks.default(O): 06-Sep-2017 19:27:23.433 INFO [main]
org.apache.catalina.startup.Catalina.start Server startup in 14458 ms
Slide 58
Slide 58 text
http://YOUR_IP:8080/national-parks
Slide 59
Slide 59 text
No network L Use curl
Map of National Parks
...
$ curl -L http://localhost:8080/national-parks
Slide 60
Slide 60 text
Supervisors provide a REST API
External Actors
Health and
Status
Supervisor
Debugging
Slide 61
Slide 61 text
Supervisors self-organize
Service
Discovery
Service Groups
Slide 62
Slide 62 text
• http://YOUR_IP:9631/services
• http://YOUR_IP:9631/services/mongodb/default/config
• http://YOUR_IP:9631/services/national-parks/default/config
REST API
Slide 63
Slide 63 text
• http://YOUR_IP:9631/services/mongodb/default/config
REST API
Slide 64
Slide 64 text
• http://YOUR_IP:9631/services/mongodb/default/config
REST API
With JSONView
Chrome Plugin
Applying Configuration
sudo hab config apply --peer 127.0.0.1 mytutorialapp.default 1 tutorial.toml
• peer - hostname or IP address of a running supervisor
• mytutorial.default - the service group
• 1 - the incarnation of this configuration
• tutorial.toml - the file with the new configuration
Slide 73
Slide 73 text
No content
Slide 74
Slide 74 text
What’s Next?
• Use a provided Habitat development environment, or install Habitat locally
• Join the Habitat Slack Team - http://slack.habitat.sh/
• Work through the tutorial at https://www.habitat.sh/tutorials/
• Explore Habitat packages on the depot - https://app.habitat.sh/
• Explore the Habitat projects - https://github.com/habitat-sh
• Read Habitat Blog posts - https://www.habitat.sh/blog/