SlideShare a Scribd company logo
Orchestrating Docker with 
Consul and Terraform
Mitchell Hashimoto 
@mitchellh
HashiCorp 
Powering the software-managed datacenter. 
hashicorp.com
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
What’s the problem? 
“Orchestration” and why it is needed in a Docker world
Docker Solves a lot of Problems 
Packaging Docker Image 
Docker Registry 
Docker Host 
Distribution 
Execution
Other Pieces to the Puzzle 
• Infrastructure lifecycle and provisioning 
• Monitoring 
• Discovery 
• Orchestration 
• Transitioning to Docker
Infrastructure Lifecycle and Provisioning 
Datacenter 
Server Server Server 
Server Server Server 
Server Server Server 
DNS 
Database 
CDN
Infrastructure Lifecycle and Provisioning 
Datacenter 
Server Server Server 
Server Server Server 
Server Server Server 
DNS 
Database 
CDN 
• Docker hosts 
• Networking 
• Storage 
• Service providers 
(ex. DNS, CDN, 
etc)
Infrastructure Lifecycle and Provisioning 
Datacenter 
Server Server Server 
Server Server Server 
Server Server Server 
DNS 
Database 
CDN 
• Changing/Iterating 
• Rolling deploys 
• Canaries
Monitoring 
Container Container Container 
Container Container Container 
Virtual Virtual Virtual 
Physical (Machine) 
• Node 
• Container 
• Service 
• Propagation of this 
information 
Service Service Service
Discovery 
• “Where is service foo?” (database, web app, api, etc.) 
• Multi-datacenter 
• Service providers (Database as a Service, etc.) 
• Physical nodes + containers + non-Docker 
• Service configuration: “What is my configuration?”
Transitioning to Docker 
• Transition isn’t a single step, takes time 
• How to handle legacy + Docker and interaction?
Problems Not Inherent to Docker 
• Not new, not caused by Docker, will exist after Docker 
• Higher density exacerbates problems at earlier stage 
• New aspect: core datacenter functionality is shrinking! 
• Number of servers and containers will only grow, but the number of 
servers/containers we run/manage will shrink over time. 
• Infrastructure lifecycle, discovery, monitoring, orchestration problems 
still exist yesterday, now, and in the future.
Consul and Terraform 
Infrastructure lifecycle, service discovery, 
monitoring, and orchestration at scale 
for all infrastructures.
terraform.io
Build, combine, and launch 
infrastructure safely and efficiently. 
terraform.io
Terraform Goals 
• Unified view of modern datacenter with infrastructure as code 
• Compose multiple tiers (IaaS to PaaS to SaaS) 
• Safely change/iterate infrastructure 
• One workflow, technology agnostic 
• “No more dashboards.”
Infrastructure as Code 
DigitalOcean Droplet with DNS in DNSimple 
resource "digitalocean_droplet" "web" { 
name = "tf-web" 
size = "512mb" 
image = "centos-5-8-x32" 
region = "sfo1" 
} 
resource "dnsimple_record" "hello" { 
domain = "example.com" 
name = "test" 
value = "${digitalocean_droplet.web.ipv4_address}" 
type = "A" 
}
Infrastructure as Code 
DigitalOcean Droplet with DNS in DNSimple 
resource "digitalocean_droplet" "web" { 
name = "tf-web" 
size = "512mb" 
image = "centos-5-8-x32" 
region = "sfo1" 
} 
resource "dnsimple_record" "hello" { 
domain = "example.com" 
name = "test" 
value = "${digitalocean_droplet.web.ipv4_address}" 
type = "A" 
}
Infrastructure as Code 
DigitalOcean Droplet with DNS in DNSimple 
resource "digitalocean_droplet" "web" { 
name = "tf-web" 
size = "512mb" 
image = "centos-5-8-x32" 
region = "sfo1" 
} 
resource "dnsimple_record" "hello" { 
domain = "example.com" 
name = "test" 
value = "${digitalocean_droplet.web.ipv4_address}" 
type = "A" 
}
Infrastructure as Code 
DigitalOcean Droplet with DNS in DNSimple 
resource "digitalocean_droplet" "web" { 
name = "tf-web" 
size = "512mb" 
image = "centos-5-8-x32" 
region = "sfo1" 
} 
resource "dnsimple_record" "hello" { 
domain = "example.com" 
name = "test" 
value = "${digitalocean_droplet.web.ipv4_address}" 
type = "A" 
}
Infrastructure as Code 
• Human friendly config, JSON compatible 
• Text format makes it version-able, VCS-friendly 
• Infrastructure as code on a level not before possible
Compose Multiple Tiers / Providers
Providers 
• Integration point 
• Expose resources (“aws_instance”, “dnsimple_record”, etc.) 
• CRUD API 
• Core vs. Providers simplifies logic for integrators
Provider Composition 
• “Layer cake” 
• Provider for each layer 
• Unified configuration 
Container Container Container 
Container Container Container 
Virtual Virtual Virtual 
IaaS (OpenStack, etc.) 
• One step: “terraform apply” Physical (Machine)
Safely Change/Iterate 
Terraform Plan 
+ digitalocean_droplet.web 
backups: "" => "<computed>" 
image: "" => "centos-5-8-x32" 
ipv4_address: "" => "<computed>" 
ipv4_address_private: "" => "<computed>" 
name: "" => "tf-web" 
private_networking: "" => "<computed>" 
region: "" => "sfo1" 
size: "" => "512mb" 
status: "" => "<computed>" 
+ dnsimple_record.hello 
domain: "" => "example.com" 
domain_id: "" => "<computed>" 
hostname: "" => "<computed>" 
name: "" => "test" 
priority: "" => "<computed>" 
ttl: "" => "<computed>" 
type: "" => "A" 
value: "" => "${digitalocean_droplet.web.ipv4_address}"
Safely Change/Iterate 
Terraform Plan 
+ digitalocean_droplet.web 
backups: "" => "<computed>" 
image: "" => "centos-5-8-x32" 
ipv4_address: "" => "<computed>" 
ipv4_address_private: "" => "<computed>" 
name: "" => "tf-web" 
private_networking: "" => "<computed>" 
region: "" => "sfo1" 
size: "" => "512mb" 
status: "" => "<computed>" 
+ dnsimple_record.hello 
domain: "" => "example.com" 
domain_id: "" => "<computed>" 
hostname: "" => "<computed>" 
name: "" => "test" 
priority: "" => "<computed>" 
ttl: "" => "<computed>" 
type: "" => "A" 
value: "" => "${digitalocean_droplet.web.ipv4_address}"
Safely Change/Iterate 
Terraform Plan 
+ digitalocean_droplet.web 
backups: "" => "<computed>" 
image: "" => "centos-5-8-x32" 
ipv4_address: "" => "<computed>" 
ipv4_address_private: "" => "<computed>" 
name: "" => "tf-web" 
private_networking: "" => "<computed>" 
region: "" => "sfo1" 
size: "" => "512mb" 
status: "" => "<computed>" 
+ dnsimple_record.hello 
domain: "" => "example.com" 
domain_id: "" => "<computed>" 
hostname: "" => "<computed>" 
name: "" => "test" 
priority: "" => "<computed>" 
ttl: "" => "<computed>" 
type: "" => "A" 
value: "" => "${digitalocean_droplet.web.ipv4_address}"
Safely Change/Iterate 
• Plan shows you what will happen 
• Save plans to guarantee what will happen 
• Plans show reasons for certain actions (such as re-create) 
• Prior to Terraform: Operators had to “divine” change ordering, 
parallelization, rollout effect.
Other Features 
• Modules 
• Provisioners (remote-exec, local-exec, etc.) 
• Parameterization 
• Outputs 
• One command run: terraform run github.com/foo/bar
consul.io
Service discovery, configuration, and 
orchestration made easy. Distributed, 
highly available, and datacenter-aware.
Service Discovery 
Where is service foo?
Service Discovery 
Service Discovery via DNS or HTTP 
$ dig web-frontend.service.consul. +short 
10.0.3.89 
10.0.1.46 
$ curl http://localhost:8500/v1/catalog/service/web-frontend 
[{ 
“Node”: “node-e818f1”, 
“Address”: “10.0.3.89”, 
“ServiceID”: “web-frontend”, 
… 
}]
Service Discovery 
• DNS is legacy-friendly. No application changes required. 
• HTTP returns rich metadata. 
• Discover both internal and external services 
(such as service providers)
Failure Detection 
Is service foo 
healthy/available?
Failure Detection
Failure Detection 
• DNS won’t return non-healthy services or nodes. 
• HTTP has endpoints to list health state of catalog.
Key/Value Storage 
What is the config of service foo?
Key/Value Storage 
Setting and Getting a Key 
$ curl –X PUT –d ‘bar’ http://localhost:8500/v1/kv/foo 
true 
$ curl http://localhost:8500/v1/kv/foo?raw 
bar
Key/Value Storage 
• Highly available storage of configuration. 
• Turn knobs without big configuration management process. 
• Watch keys (long poll) for changes 
• ACLs on key/value to protect sensitive information
Multi-Datacenter
Multi-Datacenter 
Service Discovery 
$ dig web-frontend.singapore.service.consul. +short 
10.3.3.33 
10.3.1.18 
$ dig web-frontend.germany.service.consul. +short 
10.7.3.41 
10.7.1.76
Multi-Datacenter 
Setting and Getting a Key 
$ curl http://localhost:8500/v1/kv/foo?raw&dc=asia 
true 
$ curl http://localhost:8500/v1/kv/foo?raw&dc=eu 
false
Multi-Datacenter 
• Local by default 
• Can query other datacenters however you may need to 
• Can view all datacenters within one UI
Orchestration 
Events, Exec, Watches
Events, Exec, Watches 
Dispatching Custom Events 
$ consul event deploy 6DF7FE 
… 
$ consul watch -type event -name deploy /usr/bin/deploy.sh 
… 
$ consul exec -service web /usr/bin/deploy.sh 
…
Events, Exec, Watches 
• Powerful orchestration tools 
• Pros/cons to each approach, use the right tool for the job 
• All approaches proven to scale to thousands of agents
Operational Bullet Points 
• Leader election via Raft 
• Gossip protocol for aliveness 
• Three consistency models: default, consistent, and stale 
• Encryption, ACLs available 
• Real world usage to thousands of agents per datacenter
Consul and Terraform + Docker
Consul + Docker 
• progrium/consul (docker-consul) 
• registrator 
• Two options: Consul agent in or out of another Docker container. 
Both are easy, well supported.
Consul: To Docker or Not to Docker 
• Consul in Docker: Health checks must be network based due to 
isolation. 
• Consul on host: Can run health checks that enter container, invoke 
Docker for rich checks (file tests, pid tests, etc.) 
• Up to you, both ways work with the above caveats.
Terraform + Docker 
• Create all infrastructure components, not just Docker hosts: Load 
balancers, DNS, networking, storage, external service providers, etc. 
• Deploy Docker with static assignment (Docker provider, remote-exec), 
or schedulers (ECS, Mesos, Kubernetes, etc.)
Thanks! 
hashicorp.com

More Related Content

PDF
Getting Started Running Apache Spark on Apache Mesos
PDF
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
PPTX
Terraform Modules Restructured
PDF
Datacenter Computing with Apache Mesos - シリコンバレー日本人駐在員Meetup
PPTX
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
PDF
Bootstrapping Microservices with Kafka, Akka and Spark
PPTX
Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Ja...
PDF
TDC2016POA | Trilha Infraestrutura - Apache Mesos & Marathon: gerenciando rem...
Getting Started Running Apache Spark on Apache Mesos
Cloud Foundry Summit 2015: Building a Robust Cloud Foundry (HA, Security and DR)
Terraform Modules Restructured
Datacenter Computing with Apache Mesos - シリコンバレー日本人駐在員Meetup
Real-Time Distributed and Reactive Systems with Apache Kafka and Apache Accumulo
Bootstrapping Microservices with Kafka, Akka and Spark
Javantura v3 - Conquer the Internet of Things with Java and Docker – Johan Ja...
TDC2016POA | Trilha Infraestrutura - Apache Mesos & Marathon: gerenciando rem...

What's hot (19)

PDF
Lightbend Fast Data Platform
PDF
Deploying Docker Containers at Scale with Mesos and Marathon
PPTX
Matt Franklin - Apache Software (Geekfest)
ODP
Devoxx 2016 talk: Going Global with Nomad and Google Cloud Platform
PPTX
Data Architectures for Robust Decision Making
PDF
Service discovery in mesos miguel, Angel Guillen
PPTX
Have your cake and eat it too
PPTX
Large scale near real-time log indexing with Flume and SolrCloud
PDF
Stac summit june 14th - goodbye datalakes
PPTX
Episode 3: Kubernetes and Big Data Services
PDF
Streaming Processing with a Distributed Commit Log
PDF
Scaling Big Data with Hadoop and Mesos
PPTX
Developing with the Go client for Apache Kafka
PDF
Developing Real-Time Data Pipelines with Apache Kafka
PDF
Getting Pulsar Spinning_Addison Higham
PPTX
Deploying Apache Flume to enable low-latency analytics
PDF
Containerizing Distributed Pipes
PPTX
Eron Wright - Flink Security Enhancements
PPTX
HadoopCon- Trend Micro SPN Hadoop Overview
Lightbend Fast Data Platform
Deploying Docker Containers at Scale with Mesos and Marathon
Matt Franklin - Apache Software (Geekfest)
Devoxx 2016 talk: Going Global with Nomad and Google Cloud Platform
Data Architectures for Robust Decision Making
Service discovery in mesos miguel, Angel Guillen
Have your cake and eat it too
Large scale near real-time log indexing with Flume and SolrCloud
Stac summit june 14th - goodbye datalakes
Episode 3: Kubernetes and Big Data Services
Streaming Processing with a Distributed Commit Log
Scaling Big Data with Hadoop and Mesos
Developing with the Go client for Apache Kafka
Developing Real-Time Data Pipelines with Apache Kafka
Getting Pulsar Spinning_Addison Higham
Deploying Apache Flume to enable low-latency analytics
Containerizing Distributed Pipes
Eron Wright - Flink Security Enhancements
HadoopCon- Trend Micro SPN Hadoop Overview
Ad

Viewers also liked (20)

PPTX
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
PPTX
An intro to Docker, Terraform, and Amazon ECS
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
PPTX
Comprehensive Terraform Training
PDF
CloudFormation vs Terraform vs Ansible
PDF
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
PDF
Building Web Scale Apps with Docker and Mesos by Alex Rukletsov (Mesosphere)
PDF
Terraform: An Overview & Introduction
PDF
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
PDF
Building infrastructure with Terraform (Google)
PDF
Choosing the Right Framework for Running Docker Containers in Prod
PPTX
Scaling Development Environments with Docker
PDF
Clocker: Managing Container Networking and Placement
PPTX
TOSCA and Cloudify
PPTX
Container Orchestration
PDF
Container Orchestration Wars (Micro Edition)
PPTX
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
PDF
Docker and Radio Astronomy - Containing Fragile Scientific Software by Gijs M...
PPTX
Opinionated containers and the future of game servers by Brendan Fosberry
PPTX
Migrating a large code-base to containers by Doug Johnson and Jonathan Lozins...
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
An intro to Docker, Terraform, and Amazon ECS
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Comprehensive Terraform Training
CloudFormation vs Terraform vs Ansible
Docker at Shopify: From This-Looks-Fun to Production by Simon Eskildsen (Shop...
Building Web Scale Apps with Docker and Mesos by Alex Rukletsov (Mesosphere)
Terraform: An Overview & Introduction
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Building infrastructure with Terraform (Google)
Choosing the Right Framework for Running Docker Containers in Prod
Scaling Development Environments with Docker
Clocker: Managing Container Networking and Placement
TOSCA and Cloudify
Container Orchestration
Container Orchestration Wars (Micro Edition)
Scaling Your App With Docker Swarm using Terraform, Packer on Openstack
Docker and Radio Astronomy - Containing Fragile Scientific Software by Gijs M...
Opinionated containers and the future of game servers by Brendan Fosberry
Migrating a large code-base to containers by Doug Johnson and Jonathan Lozins...
Ad

Similar to Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto (20)

PDF
TIAD : Automating the modern datacenter
PDF
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
PDF
Atmosphere Conference 2015: Taming the Modern Datacenter
PDF
Microservices with Terraform, Docker and the Cloud. Chicago Coders Conference...
PDF
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
PDF
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
PDF
HashiStack. To the cloud and beyond...
PDF
Oracle Cloud - Infrastruktura jako kód
PPTX
Terraform Immutablish Infrastructure with Consul-Template
PDF
Microservices with Terraform, Docker and the Cloud. IJug Chicago 2017-06-06
PDF
Terraforming your Infrastructure on GCP
PDF
56k.cloud training
PDF
A case study why Zoominfo uses Terraform Cloud in high-scale environment.
PPTX
A year in Production with the Hashistack
PDF
OSDC 2017 | Taming the Modern Data Center by Seth Vargo
PDF
OSDC 2017 | Modern Secrets Management with Vault by Seth Vargo
PDF
OSDC 2017 - Seth Vargo - Taming the modern data center
PDF
Higher order infrastructure: from Docker basics to cluster management - Nicol...
PDF
State of Union - Containerz
PDF
Container orchestration
TIAD : Automating the modern datacenter
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
Atmosphere Conference 2015: Taming the Modern Datacenter
Microservices with Terraform, Docker and the Cloud. Chicago Coders Conference...
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
HashiStack. To the cloud and beyond...
Oracle Cloud - Infrastruktura jako kód
Terraform Immutablish Infrastructure with Consul-Template
Microservices with Terraform, Docker and the Cloud. IJug Chicago 2017-06-06
Terraforming your Infrastructure on GCP
56k.cloud training
A case study why Zoominfo uses Terraform Cloud in high-scale environment.
A year in Production with the Hashistack
OSDC 2017 | Taming the Modern Data Center by Seth Vargo
OSDC 2017 | Modern Secrets Management with Vault by Seth Vargo
OSDC 2017 - Seth Vargo - Taming the modern data center
Higher order infrastructure: from Docker basics to cluster management - Nicol...
State of Union - Containerz
Container orchestration

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Modernizing your data center with Dell and AMD
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
Modernizing your data center with Dell and AMD
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Digital-Transformation-Roadmap-for-Companies.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf

Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto

  • 1. Orchestrating Docker with Consul and Terraform
  • 3. HashiCorp Powering the software-managed datacenter. hashicorp.com
  • 5. What’s the problem? “Orchestration” and why it is needed in a Docker world
  • 6. Docker Solves a lot of Problems Packaging Docker Image Docker Registry Docker Host Distribution Execution
  • 7. Other Pieces to the Puzzle • Infrastructure lifecycle and provisioning • Monitoring • Discovery • Orchestration • Transitioning to Docker
  • 8. Infrastructure Lifecycle and Provisioning Datacenter Server Server Server Server Server Server Server Server Server DNS Database CDN
  • 9. Infrastructure Lifecycle and Provisioning Datacenter Server Server Server Server Server Server Server Server Server DNS Database CDN • Docker hosts • Networking • Storage • Service providers (ex. DNS, CDN, etc)
  • 10. Infrastructure Lifecycle and Provisioning Datacenter Server Server Server Server Server Server Server Server Server DNS Database CDN • Changing/Iterating • Rolling deploys • Canaries
  • 11. Monitoring Container Container Container Container Container Container Virtual Virtual Virtual Physical (Machine) • Node • Container • Service • Propagation of this information Service Service Service
  • 12. Discovery • “Where is service foo?” (database, web app, api, etc.) • Multi-datacenter • Service providers (Database as a Service, etc.) • Physical nodes + containers + non-Docker • Service configuration: “What is my configuration?”
  • 13. Transitioning to Docker • Transition isn’t a single step, takes time • How to handle legacy + Docker and interaction?
  • 14. Problems Not Inherent to Docker • Not new, not caused by Docker, will exist after Docker • Higher density exacerbates problems at earlier stage • New aspect: core datacenter functionality is shrinking! • Number of servers and containers will only grow, but the number of servers/containers we run/manage will shrink over time. • Infrastructure lifecycle, discovery, monitoring, orchestration problems still exist yesterday, now, and in the future.
  • 15. Consul and Terraform Infrastructure lifecycle, service discovery, monitoring, and orchestration at scale for all infrastructures.
  • 17. Build, combine, and launch infrastructure safely and efficiently. terraform.io
  • 18. Terraform Goals • Unified view of modern datacenter with infrastructure as code • Compose multiple tiers (IaaS to PaaS to SaaS) • Safely change/iterate infrastructure • One workflow, technology agnostic • “No more dashboards.”
  • 19. Infrastructure as Code DigitalOcean Droplet with DNS in DNSimple resource "digitalocean_droplet" "web" { name = "tf-web" size = "512mb" image = "centos-5-8-x32" region = "sfo1" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${digitalocean_droplet.web.ipv4_address}" type = "A" }
  • 20. Infrastructure as Code DigitalOcean Droplet with DNS in DNSimple resource "digitalocean_droplet" "web" { name = "tf-web" size = "512mb" image = "centos-5-8-x32" region = "sfo1" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${digitalocean_droplet.web.ipv4_address}" type = "A" }
  • 21. Infrastructure as Code DigitalOcean Droplet with DNS in DNSimple resource "digitalocean_droplet" "web" { name = "tf-web" size = "512mb" image = "centos-5-8-x32" region = "sfo1" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${digitalocean_droplet.web.ipv4_address}" type = "A" }
  • 22. Infrastructure as Code DigitalOcean Droplet with DNS in DNSimple resource "digitalocean_droplet" "web" { name = "tf-web" size = "512mb" image = "centos-5-8-x32" region = "sfo1" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${digitalocean_droplet.web.ipv4_address}" type = "A" }
  • 23. Infrastructure as Code • Human friendly config, JSON compatible • Text format makes it version-able, VCS-friendly • Infrastructure as code on a level not before possible
  • 24. Compose Multiple Tiers / Providers
  • 25. Providers • Integration point • Expose resources (“aws_instance”, “dnsimple_record”, etc.) • CRUD API • Core vs. Providers simplifies logic for integrators
  • 26. Provider Composition • “Layer cake” • Provider for each layer • Unified configuration Container Container Container Container Container Container Virtual Virtual Virtual IaaS (OpenStack, etc.) • One step: “terraform apply” Physical (Machine)
  • 27. Safely Change/Iterate Terraform Plan + digitalocean_droplet.web backups: "" => "<computed>" image: "" => "centos-5-8-x32" ipv4_address: "" => "<computed>" ipv4_address_private: "" => "<computed>" name: "" => "tf-web" private_networking: "" => "<computed>" region: "" => "sfo1" size: "" => "512mb" status: "" => "<computed>" + dnsimple_record.hello domain: "" => "example.com" domain_id: "" => "<computed>" hostname: "" => "<computed>" name: "" => "test" priority: "" => "<computed>" ttl: "" => "<computed>" type: "" => "A" value: "" => "${digitalocean_droplet.web.ipv4_address}"
  • 28. Safely Change/Iterate Terraform Plan + digitalocean_droplet.web backups: "" => "<computed>" image: "" => "centos-5-8-x32" ipv4_address: "" => "<computed>" ipv4_address_private: "" => "<computed>" name: "" => "tf-web" private_networking: "" => "<computed>" region: "" => "sfo1" size: "" => "512mb" status: "" => "<computed>" + dnsimple_record.hello domain: "" => "example.com" domain_id: "" => "<computed>" hostname: "" => "<computed>" name: "" => "test" priority: "" => "<computed>" ttl: "" => "<computed>" type: "" => "A" value: "" => "${digitalocean_droplet.web.ipv4_address}"
  • 29. Safely Change/Iterate Terraform Plan + digitalocean_droplet.web backups: "" => "<computed>" image: "" => "centos-5-8-x32" ipv4_address: "" => "<computed>" ipv4_address_private: "" => "<computed>" name: "" => "tf-web" private_networking: "" => "<computed>" region: "" => "sfo1" size: "" => "512mb" status: "" => "<computed>" + dnsimple_record.hello domain: "" => "example.com" domain_id: "" => "<computed>" hostname: "" => "<computed>" name: "" => "test" priority: "" => "<computed>" ttl: "" => "<computed>" type: "" => "A" value: "" => "${digitalocean_droplet.web.ipv4_address}"
  • 30. Safely Change/Iterate • Plan shows you what will happen • Save plans to guarantee what will happen • Plans show reasons for certain actions (such as re-create) • Prior to Terraform: Operators had to “divine” change ordering, parallelization, rollout effect.
  • 31. Other Features • Modules • Provisioners (remote-exec, local-exec, etc.) • Parameterization • Outputs • One command run: terraform run github.com/foo/bar
  • 33. Service discovery, configuration, and orchestration made easy. Distributed, highly available, and datacenter-aware.
  • 34. Service Discovery Where is service foo?
  • 35. Service Discovery Service Discovery via DNS or HTTP $ dig web-frontend.service.consul. +short 10.0.3.89 10.0.1.46 $ curl http://localhost:8500/v1/catalog/service/web-frontend [{ “Node”: “node-e818f1”, “Address”: “10.0.3.89”, “ServiceID”: “web-frontend”, … }]
  • 36. Service Discovery • DNS is legacy-friendly. No application changes required. • HTTP returns rich metadata. • Discover both internal and external services (such as service providers)
  • 37. Failure Detection Is service foo healthy/available?
  • 39. Failure Detection • DNS won’t return non-healthy services or nodes. • HTTP has endpoints to list health state of catalog.
  • 40. Key/Value Storage What is the config of service foo?
  • 41. Key/Value Storage Setting and Getting a Key $ curl –X PUT –d ‘bar’ http://localhost:8500/v1/kv/foo true $ curl http://localhost:8500/v1/kv/foo?raw bar
  • 42. Key/Value Storage • Highly available storage of configuration. • Turn knobs without big configuration management process. • Watch keys (long poll) for changes • ACLs on key/value to protect sensitive information
  • 44. Multi-Datacenter Service Discovery $ dig web-frontend.singapore.service.consul. +short 10.3.3.33 10.3.1.18 $ dig web-frontend.germany.service.consul. +short 10.7.3.41 10.7.1.76
  • 45. Multi-Datacenter Setting and Getting a Key $ curl http://localhost:8500/v1/kv/foo?raw&dc=asia true $ curl http://localhost:8500/v1/kv/foo?raw&dc=eu false
  • 46. Multi-Datacenter • Local by default • Can query other datacenters however you may need to • Can view all datacenters within one UI
  • 48. Events, Exec, Watches Dispatching Custom Events $ consul event deploy 6DF7FE … $ consul watch -type event -name deploy /usr/bin/deploy.sh … $ consul exec -service web /usr/bin/deploy.sh …
  • 49. Events, Exec, Watches • Powerful orchestration tools • Pros/cons to each approach, use the right tool for the job • All approaches proven to scale to thousands of agents
  • 50. Operational Bullet Points • Leader election via Raft • Gossip protocol for aliveness • Three consistency models: default, consistent, and stale • Encryption, ACLs available • Real world usage to thousands of agents per datacenter
  • 52. Consul + Docker • progrium/consul (docker-consul) • registrator • Two options: Consul agent in or out of another Docker container. Both are easy, well supported.
  • 53. Consul: To Docker or Not to Docker • Consul in Docker: Health checks must be network based due to isolation. • Consul on host: Can run health checks that enter container, invoke Docker for rich checks (file tests, pid tests, etc.) • Up to you, both ways work with the above caveats.
  • 54. Terraform + Docker • Create all infrastructure components, not just Docker hosts: Load balancers, DNS, networking, storage, external service providers, etc. • Deploy Docker with static assignment (Docker provider, remote-exec), or schedulers (ECS, Mesos, Kubernetes, etc.)

Editor's Notes

  • #5: You may recognize some of our tools, we make Vagrant, Packer, Serf, Consul and Terraform.
  • #20: This is an example of Terraform configuration. In this example, we’re describing setting up a DO droplet with DNS in DNSimple. This is a good example of combining both IaaS and SaaS, or composing providers.
  • #25: This shows the output of `terraform graph`, which gives you a visual graph of how your datacenter dependencies are laid out.