SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Declarative
Infrastructure
Tools
Alex Conway
Release Automation Engineer,
DataRobot
alex@datarobot.com
Who Am I?
● Former particle physics guy
● Release Automation Engineer
● Boston
● AWS, Linux, Python, Ansible, Docker
DISCLAIMER:
What’s This All About?
● Some tools I like.
● Some fun projects I’ve worked on.
● Declarative Tools.
● Creating simple interfaces to powerful
tools.
● Maybe change the way you think about
your next project.
What’s It All For?
● Need to create many independent test
environments.
● Different sizes and configurations.
● Give devs power to make their own.
About DataRobot
https://www.datarobot.com/
The Company
Our Vision:
● To become the world’s go-to resource for data science
and machine learning tools
Our Product:
● Automates the processes of data science
● Creates highly accurate predictive models
● Runs on open-source machine learning libraries
● Allows data scientists to work faster and smarter
● Both cloud and enterprise/on-prem
DataRobot Application Stack
● Application
○ Python
○ Node.js
● Database
○ MongoDB
○ Redis
● Storage
○ S3/Gluster/HDFS
Docker!
Imperative
vs
Declarative
Imperative vs Declarative
Declarative
● Please give me a
donut
Imperative
● Please make some
dough
● Then shape it into a
circle
● Then fry it
Imperative vs Declarative
Declarative
● Describe a state
● Explicit
dependencies
● Simple
● Hard
Imperative
● Describe a process
● Implicit
dependencies
● Complex
● Easy
Make
by GNU
https://www.gnu.org/software/make/
WTF is… Make?
● Build tool with
declarative syntax
● Dependency graph
● Idempotent
● Do any step out of order
# File: Makefile
raw.dough:
./make_dough.sh
circle.dough: raw.dough
./make_circle.sh raw.dough
donut: circle.dough
./fry.sh circle.dough
$ make donut
./make_dough.sh
./make_circle.sh raw.dough
./fry.sh circle.dough
make: execvp: ./fry.sh: Permission denied
make: *** [donut] Error 127
$ sudo make donut
./fry.sh circle.dough
Okay.
_.-------._
.' ___ '.
/ (___) 
|'._ _.'|
| `'-----'` |
 /
'-.______..-'
Terraform
by Hashicorp
https://www.terraform.io/
WTF is… Terraform?
● Infrastructure as Code
○ Describe your whole infrastructure in simple, declarative
configuration language.
○ AWS, DigitalOcean, VSphere, OpenStack, and more.
● Resource Graph
○ Track dependencies between resources.
● Mutate State
○ Transition between states with ease, updating all affected
resources.
“Terraform is a tool for building, changing, and versioning infrastructure
safely and efficiently.” - https://www.terraform.io/intro/index.html
# File: test/terraform-test.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "hello_world" {
ami = "ami-deadbeef"
availability_zone = "us-east-1a"
instance_type = "t2.micro"
key_name = "my_key"
subnet_id = "subnet-deadbeef"
tags = {
name = "tf-test"
}
vpc_security_group_ids = ["sg-deadbeef"]
}
Basic Usage With AWS
$ cd test
$ ls
terraform-test.tf
$ terraform plan
...
Plan: 1 to add, 0 to change, 0 to destroy.
$ terraform apply
...
Apply complete! Resources: 1 added, 0 changed, 0
destroyed.
$
● Store Terraform state in shared
location, not your hard drive.
● S3, Hashicorp Atlas, any REST
service.
● Split code between folders or
repositories but share common
state.
● Currently it does not protect
from simultaneous changes to
state!
Remote State
$ terraform remote config 
-backend=s3 
-backend-config="region=us-east-1" 
-backend-config="bucket=terraform-state" 
-backend-config="key=test.tfstate"
$ terraform remote pull
$ terraform plan
$ terraform apply
$ terraform remote push
$
Makefile for Terraform
Simple command wrapper to standardize Terraform
workflow.
# File: Makefile
...
remote-config:
terraform remote config $(remote_vars)
remote-pull: remote-config
terraform remote pull
get:
terraform get
plan: get remote-pull
terraform plan $(tf_vars)
apply: plan get remote-pull
terraform apply $(tf_vars); 
terraform remote push
Terraform
● Describe state
● Migrate state
● Share state
● Infrastructure as
Code!
● Write out
instructions
○ Declarative tasks,
imperative plays
● Hard to keep track
of state
● Hard to make
arbitrary changes
Ansible/scripts
Docker
Compose
by Docker
https://docs.docker.com/compose/
WTF is… Docker Compose?
● YAML config file for defining Dockerized
services
○ Image, command, ports, volumes, links, etc.
○ Declarative!
“Compose is a tool for defining and running multi-container Docker
applications. With Compose, you use a Compose file to configure your
application’s services. Then, using a single command, you create and
start all the services from your configuration.”
- https://docs.docker.com/compose/overview/
# File: docker-compose.yml
# Adapted from https://docs.docker.
com/compose/wordpress/
---
wordpress:
build: ./wordpress/
command: php -S 0.0.0.0:8000 -t /code
ports:
- "8000:8000"
links:
- mysql
volumes:
- wordpress/:/code
mysql:
image: orchardup/mysql
environment:
MYSQL_DATABASE: wordpress
$ docker-compose up -d
Creating mysql_1...
Building wordpress...
...
Successfully built efe76b2be23f
Creating wordpress_1...
$ curl localhost:8000
Welcome to Wordpress!
$
Docker Compose Example
infrastructure.tfdocker-compose.yml
Dev Ops
???
Common Solutions
● Config Management
○ Chef, Ansible, Puppet
● Networking
○ libnetwork, libkv
● Service discovery
○ Consul, Zookeeper, Etcd
● Scheduling
○ Mesos, Kubernetes
Common Problems
● Dev != Prod
● Prod is very complex
○ Devs don’t know it
● Infrastructure tied to services
● Services tied to infrastructure
infrastructure.tfinfrastructure.tf.json
docker-compose.yml layout.yml
ltparse
container-from-compose
DevOps!
ltparse
by DataRobot
https://github.com/datarobot/ltparse
ltparse: ‘Flexible’ Terraform
● Want many variations
● Writing Terraform can be repetitive
● Hard to read and write
● Not designed with flexibility in mind
● Want more simple cluster definitions.
● Want to integrate with configuration
management.
ltparse: ‘Flexible’ Terraform
● Input YAML file:
○ Servers
○ Security groups
○ Elastic Load Balancers
○ route53 DNS records
● Python
○ Defaults
○ Update with YAML config
○ Write parsed.tf.json file
● terraform apply
ltparse Example# File: flexible/layout.yaml
---
servers:
- label: webserver
services:
- wordpress
- nginx
route53_record: webserver
instance_info:
instance_type: m4.xlarge
- label: db
services:
- mysql
route53_records:
- label: webserver
public: True
$ cd ../flexible
$ ls
layout.yaml
$ ltparse layout.yaml
$ ls
layout.yaml parsed.tf.json
$ export cluster_id=test-cluster
$ make plan
...
Plan: 4 to add, 0 to change, 0 to destroy.
$
ltparse Output
"resource": {
"aws_instance": {
"db": {
"ami": "${var.ami_ids.hvm}",
"associate_public_ip_address": true,
"availability_zone": "us-east-1a",
"count": 1,
"instance_type": "m4.large",
"key_name": "${var.aws.key_name}",
"subnet_id": "${terraform_remote_state.subnets.output.us-east-1a}",
"tags": {
"id": "db_${var.run_id}",
"label": "db",
"owner": "test_${var.run_id}",
"user": "${var.build_user}"
},
"vpc_security_group_ids": [
"${module.default_security_group.id}"
]
... etc
ltparse
● trafaret schema for layouts
○ Good, fast feedback
● click for cli
○ No boilerplate
○ Typed parameters
● py.test for testing
○ Fixtures
○ Test good/bad layouts
● setuptools for packaging
ltparse Bonus
py.test fixtures for testing layout parser
# File: tests/layouts/bad/no_target.yaml
---
route53_records:
- label: bad
domain: domain
servers:
- label: server
expects: !!python/object/apply:ltparse.
parser.ConfigurationError [route53 record
label `bad` not applied to any instances or
elbs]
def test_full_layouts_bad(test_bad_layout):
"""
For each layout in tests/layouts/bad, assert that running
format_data fails with the exception and message defined in
the layout.
"""
expected_exception = test_bad_layout['expects']
with pytest.raises(type(expected_exception)) as excinfo:
format_data(test_bad_layout)
assert expected_exception.message == str(excinfo.value)
infrastructure.tf.json
docker-compose.yml layout.yml
ltparse
container-from-compose
Container
From
Compose
by DataRobot
● An Ansible Role
○ Take compose file
○ Take layout
○ Take infrastructure
○ Make distributed app
● Benefits
○ One config for dev and prod
○ Simple input, simple output
○ Generic deployment
WTF is… Container From Compose?
Compose and Layout
# File: layout.yaml
---
servers:
- label: web
services:
- wordpress
route53_record: wordpress
instance_info:
instance_type: m4.xlarge
- label: db
services:
- mysql
route53_records:
- label: wordpress
public: true
# File: docker-compose.yml
---
wordpress:
build: ./wordpress
command: php -S 0.0.0.0:8000 -t /code
links:
- mysql
mysql:
image: orchardup/mysql
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: pass
Ansible Playbook
● Traditionally:
○ Very imperative
○ Do this, do that, then you
have a site
○ Application-specific
○ Config is distributed; hard to
understand final state
● Now:
○ Very declarative
○ Config is centralized
○ Very generic
# File: inventory/site.inventory
[mysql:children]
tag_id_db_talk_test
[wordpress:children]
tag_id_web_talk_test
# File: site.yml
---
- hosts: mysql:wordpress
vars_files:
- docker-compose.yml
- services.yml
roles:
- container-from-compose
Container-From-Compose
● Install dependencies
○ Use role meta to create
dependency graph!
● Copy code/config
● Build any images
● Start containers
1 ---
2 - name: Example services list
3 set_fact:
4 services_list: "{{group_names | intersect(defined_services )}}"
5
6 - name: Start docker containers (simplified)
7 docker:
8 name: "{{item}}"
9 image: "{{compose_vars[item]['image']}}"
10 command: "{{compose_vars[item]['command'] | default(omit)}}"
11 env: "{{drenv}}"
12 volumes: "{{compose_vars[item]['volumes'] | default(omit)}}"
13 with_items: services_list
container-from-compose example
Caveats
● Very dense Ansible code
● Some rough edges and limitations
○ Links
○ --net=host, /etc/hosts networking
● Doesn’t currently handle state changes
○ eg. can’t move service between hosts.
infrastructure.tf.json
docker-compose.yml layout.yml
ltparse
container-from-compose
Thanks!
Bonus: why not Docker Swarm?
● I’d love to try it
● Active development
○ Swarm was experimental when we started
○ Compose + Swarm is still experimental
● Swarm filters not yet supported
○ Can’t loc service to node (like NGINX to instances
with ELB)

Weitere ähnliche Inhalte

Was ist angesagt?

Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in RustInfluxData
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixInfluxData
 
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Taiwan User Group
 
opentsdb in a real enviroment
opentsdb in a real enviromentopentsdb in a real enviroment
opentsdb in a real enviromentChen Robert
 
Monitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBMonitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBGeoffrey Anderson
 
In-core compression: how to shrink your database size in several times
In-core compression: how to shrink your database size in several timesIn-core compression: how to shrink your database size in several times
In-core compression: how to shrink your database size in several timesAleksander Alekseev
 
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...PROIDEA
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...InfluxData
 
Time Series Processing with Solr and Spark
Time Series Processing with Solr and SparkTime Series Processing with Solr and Spark
Time Series Processing with Solr and SparkJosef Adersberger
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiInfluxData
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptChanghwan Yi
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINEDB
 
Time Series Data with InfluxDB
Time Series Data with InfluxDBTime Series Data with InfluxDB
Time Series Data with InfluxDBTuri, Inc.
 
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafObtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafInfluxData
 
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...Altinity Ltd
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013Andy Bunce
 
INFLUXQL & TICKSCRIPT
INFLUXQL & TICKSCRIPTINFLUXQL & TICKSCRIPT
INFLUXQL & TICKSCRIPTInfluxData
 

Was ist angesagt? (20)

Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul Dix
 
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-OnApache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
Apache Flink Training Workshop @ HadoopCon2016 - #2 DataSet API Hands-On
 
opentsdb in a real enviroment
opentsdb in a real enviromentopentsdb in a real enviroment
opentsdb in a real enviroment
 
Monitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDBMonitoring MySQL with OpenTSDB
Monitoring MySQL with OpenTSDB
 
Toy Model Overview
Toy Model OverviewToy Model Overview
Toy Model Overview
 
In-core compression: how to shrink your database size in several times
In-core compression: how to shrink your database size in several timesIn-core compression: how to shrink your database size in several times
In-core compression: how to shrink your database size in several times
 
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...
[4DEV][Łódź] Ivan Vaskevych - InfluxDB and Grafana fighting together with IoT...
 
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
Meet the Experts: Visualize Your Time-Stamped Data Using the React-Based Gira...
 
Time Series Processing with Solr and Spark
Time Series Processing with Solr and SparkTime Series Processing with Solr and Spark
Time Series Processing with Solr and Spark
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
 
Influxdb and time series data
Influxdb and time series dataInfluxdb and time series data
Influxdb and time series data
 
W3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascriptW3C HTML5 KIG-How to write low garbage real-time javascript
W3C HTML5 KIG-How to write low garbage real-time javascript
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
Time Series Data with InfluxDB
Time Series Data with InfluxDBTime Series Data with InfluxDB
Time Series Data with InfluxDB
 
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and TelegrafObtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
 
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
 
Toku DB by Aswin
Toku DB by AswinToku DB by Aswin
Toku DB by Aswin
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
INFLUXQL & TICKSCRIPT
INFLUXQL & TICKSCRIPTINFLUXQL & TICKSCRIPT
INFLUXQL & TICKSCRIPT
 

Ähnlich wie Declarative Infrastructure Tools

15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
15th Athens Big Data Meetup - 1st Talk - Running Spark On MesosAthens Big Data
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209mffiedler
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipelineAnton Babenko
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline Docker, Inc.
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing Ran Levy
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production Hung Lin
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)DECK36
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultGrzegorz Adamowicz
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...NETWAYS
 
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...Ambassador Labs
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...Jérôme Petazzoni
 
ILM - Pipeline in the cloud
ILM - Pipeline in the cloudILM - Pipeline in the cloud
ILM - Pipeline in the cloudAaron Carey
 
A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices Nebulaworks
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouJ On The Beach
 

Ähnlich wie Declarative Infrastructure Tools (20)

DevOps for database
DevOps for databaseDevOps for database
DevOps for database
 
London HUG 12/4
London HUG 12/4London HUG 12/4
London HUG 12/4
 
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
15th Athens Big Data Meetup - 1st Talk - Running Spark On Mesos
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
TIAD : Automating the modern datacenter
TIAD : Automating the modern datacenterTIAD : Automating the modern datacenter
TIAD : Automating the modern datacenter
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
 
Resilience Testing
Resilience Testing Resilience Testing
Resilience Testing
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp Vault
 
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
 
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
ILM - Pipeline in the cloud
ILM - Pipeline in the cloudILM - Pipeline in the cloud
ILM - Pipeline in the cloud
 
A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices A Hands-on Introduction on Terraform Best Concepts and Best Practices
A Hands-on Introduction on Terraform Best Concepts and Best Practices
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Scala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camouScala, docker and testing, oh my! mario camou
Scala, docker and testing, oh my! mario camou
 

Kürzlich hochgeladen

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Kürzlich hochgeladen (20)

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

Declarative Infrastructure Tools

  • 2. Who Am I? ● Former particle physics guy ● Release Automation Engineer ● Boston ● AWS, Linux, Python, Ansible, Docker
  • 4. What’s This All About? ● Some tools I like. ● Some fun projects I’ve worked on. ● Declarative Tools. ● Creating simple interfaces to powerful tools. ● Maybe change the way you think about your next project.
  • 5. What’s It All For? ● Need to create many independent test environments. ● Different sizes and configurations. ● Give devs power to make their own.
  • 7. The Company Our Vision: ● To become the world’s go-to resource for data science and machine learning tools Our Product: ● Automates the processes of data science ● Creates highly accurate predictive models ● Runs on open-source machine learning libraries ● Allows data scientists to work faster and smarter ● Both cloud and enterprise/on-prem
  • 8. DataRobot Application Stack ● Application ○ Python ○ Node.js ● Database ○ MongoDB ○ Redis ● Storage ○ S3/Gluster/HDFS Docker!
  • 10. Imperative vs Declarative Declarative ● Please give me a donut Imperative ● Please make some dough ● Then shape it into a circle ● Then fry it
  • 11. Imperative vs Declarative Declarative ● Describe a state ● Explicit dependencies ● Simple ● Hard Imperative ● Describe a process ● Implicit dependencies ● Complex ● Easy
  • 13. WTF is… Make? ● Build tool with declarative syntax ● Dependency graph ● Idempotent ● Do any step out of order # File: Makefile raw.dough: ./make_dough.sh circle.dough: raw.dough ./make_circle.sh raw.dough donut: circle.dough ./fry.sh circle.dough $ make donut ./make_dough.sh ./make_circle.sh raw.dough ./fry.sh circle.dough make: execvp: ./fry.sh: Permission denied make: *** [donut] Error 127 $ sudo make donut ./fry.sh circle.dough Okay. _.-------._ .' ___ '. / (___) |'._ _.'| | `'-----'` | / '-.______..-'
  • 15. WTF is… Terraform? ● Infrastructure as Code ○ Describe your whole infrastructure in simple, declarative configuration language. ○ AWS, DigitalOcean, VSphere, OpenStack, and more. ● Resource Graph ○ Track dependencies between resources. ● Mutate State ○ Transition between states with ease, updating all affected resources. “Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently.” - https://www.terraform.io/intro/index.html
  • 16. # File: test/terraform-test.tf provider "aws" { region = "us-east-1" } resource "aws_instance" "hello_world" { ami = "ami-deadbeef" availability_zone = "us-east-1a" instance_type = "t2.micro" key_name = "my_key" subnet_id = "subnet-deadbeef" tags = { name = "tf-test" } vpc_security_group_ids = ["sg-deadbeef"] } Basic Usage With AWS $ cd test $ ls terraform-test.tf $ terraform plan ... Plan: 1 to add, 0 to change, 0 to destroy. $ terraform apply ... Apply complete! Resources: 1 added, 0 changed, 0 destroyed. $
  • 17. ● Store Terraform state in shared location, not your hard drive. ● S3, Hashicorp Atlas, any REST service. ● Split code between folders or repositories but share common state. ● Currently it does not protect from simultaneous changes to state! Remote State $ terraform remote config -backend=s3 -backend-config="region=us-east-1" -backend-config="bucket=terraform-state" -backend-config="key=test.tfstate" $ terraform remote pull $ terraform plan $ terraform apply $ terraform remote push $
  • 18. Makefile for Terraform Simple command wrapper to standardize Terraform workflow. # File: Makefile ... remote-config: terraform remote config $(remote_vars) remote-pull: remote-config terraform remote pull get: terraform get plan: get remote-pull terraform plan $(tf_vars) apply: plan get remote-pull terraform apply $(tf_vars); terraform remote push
  • 19. Terraform ● Describe state ● Migrate state ● Share state ● Infrastructure as Code! ● Write out instructions ○ Declarative tasks, imperative plays ● Hard to keep track of state ● Hard to make arbitrary changes Ansible/scripts
  • 21. WTF is… Docker Compose? ● YAML config file for defining Dockerized services ○ Image, command, ports, volumes, links, etc. ○ Declarative! “Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.” - https://docs.docker.com/compose/overview/
  • 22. # File: docker-compose.yml # Adapted from https://docs.docker. com/compose/wordpress/ --- wordpress: build: ./wordpress/ command: php -S 0.0.0.0:8000 -t /code ports: - "8000:8000" links: - mysql volumes: - wordpress/:/code mysql: image: orchardup/mysql environment: MYSQL_DATABASE: wordpress $ docker-compose up -d Creating mysql_1... Building wordpress... ... Successfully built efe76b2be23f Creating wordpress_1... $ curl localhost:8000 Welcome to Wordpress! $ Docker Compose Example
  • 24. Common Solutions ● Config Management ○ Chef, Ansible, Puppet ● Networking ○ libnetwork, libkv ● Service discovery ○ Consul, Zookeeper, Etcd ● Scheduling ○ Mesos, Kubernetes
  • 25. Common Problems ● Dev != Prod ● Prod is very complex ○ Devs don’t know it ● Infrastructure tied to services ● Services tied to infrastructure
  • 28. ltparse: ‘Flexible’ Terraform ● Want many variations ● Writing Terraform can be repetitive ● Hard to read and write ● Not designed with flexibility in mind ● Want more simple cluster definitions. ● Want to integrate with configuration management.
  • 29. ltparse: ‘Flexible’ Terraform ● Input YAML file: ○ Servers ○ Security groups ○ Elastic Load Balancers ○ route53 DNS records ● Python ○ Defaults ○ Update with YAML config ○ Write parsed.tf.json file ● terraform apply
  • 30. ltparse Example# File: flexible/layout.yaml --- servers: - label: webserver services: - wordpress - nginx route53_record: webserver instance_info: instance_type: m4.xlarge - label: db services: - mysql route53_records: - label: webserver public: True $ cd ../flexible $ ls layout.yaml $ ltparse layout.yaml $ ls layout.yaml parsed.tf.json $ export cluster_id=test-cluster $ make plan ... Plan: 4 to add, 0 to change, 0 to destroy. $
  • 31. ltparse Output "resource": { "aws_instance": { "db": { "ami": "${var.ami_ids.hvm}", "associate_public_ip_address": true, "availability_zone": "us-east-1a", "count": 1, "instance_type": "m4.large", "key_name": "${var.aws.key_name}", "subnet_id": "${terraform_remote_state.subnets.output.us-east-1a}", "tags": { "id": "db_${var.run_id}", "label": "db", "owner": "test_${var.run_id}", "user": "${var.build_user}" }, "vpc_security_group_ids": [ "${module.default_security_group.id}" ] ... etc
  • 32. ltparse ● trafaret schema for layouts ○ Good, fast feedback ● click for cli ○ No boilerplate ○ Typed parameters ● py.test for testing ○ Fixtures ○ Test good/bad layouts ● setuptools for packaging
  • 33. ltparse Bonus py.test fixtures for testing layout parser # File: tests/layouts/bad/no_target.yaml --- route53_records: - label: bad domain: domain servers: - label: server expects: !!python/object/apply:ltparse. parser.ConfigurationError [route53 record label `bad` not applied to any instances or elbs] def test_full_layouts_bad(test_bad_layout): """ For each layout in tests/layouts/bad, assert that running format_data fails with the exception and message defined in the layout. """ expected_exception = test_bad_layout['expects'] with pytest.raises(type(expected_exception)) as excinfo: format_data(test_bad_layout) assert expected_exception.message == str(excinfo.value)
  • 36. ● An Ansible Role ○ Take compose file ○ Take layout ○ Take infrastructure ○ Make distributed app ● Benefits ○ One config for dev and prod ○ Simple input, simple output ○ Generic deployment WTF is… Container From Compose?
  • 37. Compose and Layout # File: layout.yaml --- servers: - label: web services: - wordpress route53_record: wordpress instance_info: instance_type: m4.xlarge - label: db services: - mysql route53_records: - label: wordpress public: true # File: docker-compose.yml --- wordpress: build: ./wordpress command: php -S 0.0.0.0:8000 -t /code links: - mysql mysql: image: orchardup/mysql ports: - "3306:3306" environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: pass
  • 38. Ansible Playbook ● Traditionally: ○ Very imperative ○ Do this, do that, then you have a site ○ Application-specific ○ Config is distributed; hard to understand final state ● Now: ○ Very declarative ○ Config is centralized ○ Very generic # File: inventory/site.inventory [mysql:children] tag_id_db_talk_test [wordpress:children] tag_id_web_talk_test # File: site.yml --- - hosts: mysql:wordpress vars_files: - docker-compose.yml - services.yml roles: - container-from-compose
  • 39. Container-From-Compose ● Install dependencies ○ Use role meta to create dependency graph! ● Copy code/config ● Build any images ● Start containers
  • 40. 1 --- 2 - name: Example services list 3 set_fact: 4 services_list: "{{group_names | intersect(defined_services )}}" 5 6 - name: Start docker containers (simplified) 7 docker: 8 name: "{{item}}" 9 image: "{{compose_vars[item]['image']}}" 10 command: "{{compose_vars[item]['command'] | default(omit)}}" 11 env: "{{drenv}}" 12 volumes: "{{compose_vars[item]['volumes'] | default(omit)}}" 13 with_items: services_list container-from-compose example
  • 41. Caveats ● Very dense Ansible code ● Some rough edges and limitations ○ Links ○ --net=host, /etc/hosts networking ● Doesn’t currently handle state changes ○ eg. can’t move service between hosts.
  • 44. Bonus: why not Docker Swarm? ● I’d love to try it ● Active development ○ Swarm was experimental when we started ○ Compose + Swarm is still experimental ● Swarm filters not yet supported ○ Can’t loc service to node (like NGINX to instances with ELB)