SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Terraform in production
• Scaleable web capacity
• Scaleable load balancer capacity
• Scalable service capacity
• Scaleable, repeatable, self service Elasticsearch and Cassandra
• Provisioning a new prod datacenter cut from 12+ months to 2.
• Auto scaling, using spot capacity
• Operations and Infrastructure teams:
• More efficient
• More agile
• Providing more business value
2
Key Results
3
4
5
• Wrap Terraform up to make it harder to screw up
• Makefile - easiest path - make plan / make apply

• Use allowed_account_ids in providers (AWS specifically)
6
Lesson 1:
7
• External Node Classifer
• Puppetmaster calls a script, returns node definition
• Create node definition from EC2 tags

puppet::role::elasticsearch_cluster => cluster_name=reviews

• Stop needing individual hostnames!
8
puppet ENC
• My small contributions to the community
• github.com/terraform-community-modules/tf_aws_ubuntu_ami
• github.com/terraform-community-modules/
tf_aws_availability_zones

• Modules you can reuse to stop having to hard code IDs
• make + getvariables.rb pattern
• We have internal versions at Yelp (usually to bake in our
variables.tf.json)
9
I hate magic numbers
• Standup update from a coworker:
• Yesterday: “Learned Go”
• Today: “Implemented yelpaws_instance”
• Adds “ubuntu” and “region” + “account” variables to aws_instance
• Looks up the AMI to use automatically
• Only on initial launch, puppet converges machines after that!
• https://github.com/Yelp/terraform-ami_fromhttp
10
yelpaws_instance
11
• Modules
• Don’t put your modules in a ../modules folder in the same repos.
• Make them separate repositories, and lock SHAs/tags to avoid
surprises!
• Don’t deeply nest modules - pass a module everything it needs
• Code
• type/region-environment layout
• vpc/uswest1-prod/subnets.tf
• web_frontend/uswest1-prod/webs.tf
• terraform.tfvars
12
Code layout
• Build your VPC, subnets etc with terraform
• Export as remote state
• Pull in elsewhere - eliminate magic numbers
• Much nicer solution than getvariables.rb
13
Remote state
14
“remote” state
• nsone is an awesome DNS service!
• They have a fantastic API
• I wrote my own Terraform provider!
• github.com/bobtfish/terraform-provider-nsone
• Tie together resources from multiple regions using remote state!
15
nsone
16
nsone
github.com/Yelp/terraform-provider-gitfile
• Checkout git repository
• Generate a file from a template
• Commit + Push

puppet/modules/zookeeper_cluster/data/cluster/xxxxx.yaml
17
gitfile
• Puppet code:
class { ‘role::elasticsearch_cluster’:
cluster_name => ’reviews’,
}
• Hiera lookups:
puppet/modules/elasticsearch_cluster/data/cluster/
reviews.yaml
• Can locate the ‘data’ directory somewhere else
18
puppet data as modules
• Spot fleet Terraform provider in use internally
• ‘Coming soon’ to github
19
Spot fleet
• puppet/modules/elasticsearch_clusters/data/cluster/reviews.yaml
• Move the cluster data folder out of puppet
• Add YAML for mapping of region/environment/number of nodes
• Generate terraform config (as JSON)
• Simple config
• Directly creating ASGs
• No modules
• Easy to debug!
• Automated cluster provisioning! (Just add Jenkins)
20
Managing Elasticsearch/Cassandra etc
• Bad abstraction for contextual information
• Which db server is the master? Does it have ‘master’ in it’s FQDN?
• If it does, what happens when you promote another machine?

• Need key => value for cattle not pets

• Customize your monitoring system to actually tell you what’s wrong!
• ‘The master DB has crashed’ vs ‘A db has crashed’
• ‘10-46-11-54 is dead’ vs ‘zookeeper::10-46-11-54 is dead`
21
Hostnames
• Smartstack
• Nerve (on host, monitors services)
• Synapse (run a haproxy on lo:0)
• Hacheck (cache healthcheck results to rate limit)
• qdisc_tools (seamless haproxy reloads)
• yocalhost: 169.254.255.254
• Reachable from the machine
• Reachable from inside Docker
• Each service has a fixed port
22
Service discovery
• Terraform is really, really young.
• It has some serious issues and limitations currently
23
The bad news
• Terraform is really, really young.
• It has some serious issues and limitations currently
24
The bad news
The good news
• It’s moving really fast
• None of the things needed fundamentally change the model
• Unfortunately, provider aliases don’t work in terraform modules
• We want to provision all ‘prod’ ES clusters in one shot
• So we just generate raw terraform resources, without using a module

• Works, but it’d be nice to have more separation
• ‘Make all the Elasticsearch clusters’
• ‘Make an individual Elasticsearch cluster’

• Should be separate concerns IMO
25
Multi region
• "Terraform is really hard to debug”
• Modules make this 10x worse.
• TF_LOG=1 is useful for provider authors.
• NOT useful for Terraform users
26
Debugging
output “thing_ids” {
value = “${join(“,”, aws_instance.foo.*.id)}”
}
${split(“,” module.foo.thing)}





const stringListDelim = `B780FFEC-B661-4EB8-9236-
A01737AD98B6`
27
Data structures
• Lots of corner cases where they don’t work.
• Some cases where they work sometimes
28
Counts and Interpolation
• Don’t try to put your domain logic into Terraform!
• Write some (simple!) classes for your domain
• Make them serialize out to Terraform resources in JSON
• Done!
29
KISS
• 0.7 will fix some of my biggest complaints

• Ability to move state
• Enables refactoring existing resources into modules
• Complex data structure support
• No more split() join()
30
Terraform 0.7
• Twitter: @bobtfish
• IRC: #terraform (t0m)
• github.com/bobtfish
• github.com/Yelp
• github.com/terraform-community-modules
31
Thanks

Contenu connexe

Tendances

Tendances (20)

Wanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerWanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-docker
 
AtlasCamp 2015: How to deliver radical architectural change without the custo...
AtlasCamp 2015: How to deliver radical architectural change without the custo...AtlasCamp 2015: How to deliver radical architectural change without the custo...
AtlasCamp 2015: How to deliver radical architectural change without the custo...
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
 
AWS Lambda at JUST EAT
AWS Lambda at JUST EATAWS Lambda at JUST EAT
AWS Lambda at JUST EAT
 
Kube-AWS
Kube-AWSKube-AWS
Kube-AWS
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform in action
Terraform in actionTerraform in action
Terraform in action
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Ansible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel AvivAnsible on aws - Pop-up Loft Tel Aviv
Ansible on aws - Pop-up Loft Tel Aviv
 
Case Study: Using Terraform and Packer to deploy go applications to AWS
Case Study: Using Terraform and Packer to deploy go applications to AWSCase Study: Using Terraform and Packer to deploy go applications to AWS
Case Study: Using Terraform and Packer to deploy go applications to AWS
 
Terraform
TerraformTerraform
Terraform
 
ILM - Pipeline in the cloud
ILM - Pipeline in the cloudILM - Pipeline in the cloud
ILM - Pipeline in the cloud
 
Terraform: Configuration Management for Cloud Services
Terraform: Configuration Management for Cloud ServicesTerraform: Configuration Management for Cloud Services
Terraform: Configuration Management for Cloud Services
 
Terraform
TerraformTerraform
Terraform
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
 
Micro services infrastructure with AWS and Ansible
Micro services infrastructure with AWS and AnsibleMicro services infrastructure with AWS and Ansible
Micro services infrastructure with AWS and Ansible
 
Automating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngageAutomating aws infrastructure and code deployments using Ansible @WebEngage
Automating aws infrastructure and code deployments using Ansible @WebEngage
 
"On-premises" FaaS on Kubernetes
"On-premises" FaaS on Kubernetes"On-premises" FaaS on Kubernetes
"On-premises" FaaS on Kubernetes
 
Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
 

En vedette

En vedette (20)

London HUG 14/3
London HUG 14/3London HUG 14/3
London HUG 14/3
 
London HUG 19/5 - Kubernetes and vault
London HUG 19/5 - Kubernetes and vaultLondon HUG 19/5 - Kubernetes and vault
London HUG 19/5 - Kubernetes and vault
 
London HUG 14/4 - Deploying and Discovering at Scale with Consul and Nomad
London HUG 14/4 - Deploying and Discovering at Scale with Consul and NomadLondon HUG 14/4 - Deploying and Discovering at Scale with Consul and Nomad
London HUG 14/4 - Deploying and Discovering at Scale with Consul and Nomad
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
Betabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticasBetabeers Barcelona - Buenas prácticas
Betabeers Barcelona - Buenas prácticas
 
London HUG 14/4 - Infratructure mgmt
London HUG 14/4 - Infratructure mgmtLondon HUG 14/4 - Infratructure mgmt
London HUG 14/4 - Infratructure mgmt
 
How to improve your moodle site performance
How to improve your moodle site performanceHow to improve your moodle site performance
How to improve your moodle site performance
 
Packer
PackerPacker
Packer
 
Entorno de desarrollo rápido con Vagrant
Entorno de desarrollo rápido con VagrantEntorno de desarrollo rápido con Vagrant
Entorno de desarrollo rápido con Vagrant
 
Terraform and cloud.ca
Terraform and cloud.caTerraform and cloud.ca
Terraform and cloud.ca
 
Terraform
TerraformTerraform
Terraform
 
Rapid Infrastructure Provisioning
Rapid Infrastructure ProvisioningRapid Infrastructure Provisioning
Rapid Infrastructure Provisioning
 
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
Introduction to Packer and Suitcase: A Packer-based OS Image Build SystemIntroduction to Packer and Suitcase: A Packer-based OS Image Build System
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
 
Terraform
TerraformTerraform
Terraform
 
Infrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to TerraformInfrastructure as Code: Introduction to Terraform
Infrastructure as Code: Introduction to Terraform
 
Vagrant y Docker - Guía práctica de uso
Vagrant y Docker - Guía práctica de usoVagrant y Docker - Guía práctica de uso
Vagrant y Docker - Guía práctica de uso
 
Terraform at Scale
Terraform at ScaleTerraform at Scale
Terraform at Scale
 
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-TannerDevOps - Infrastructure as Code by Andre Marcelo-Tanner
DevOps - Infrastructure as Code by Andre Marcelo-Tanner
 
Terraform: Cloud Configuration Management (WTC/IPC'16)
Terraform: Cloud Configuration Management (WTC/IPC'16)Terraform: Cloud Configuration Management (WTC/IPC'16)
Terraform: Cloud Configuration Management (WTC/IPC'16)
 

Similaire à London Hug 19/5 - Terraform in Production

Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
DoKC
 
Puppet camp london nov 2014 slides (1)
Puppet camp london nov 2014   slides (1)Puppet camp london nov 2014   slides (1)
Puppet camp london nov 2014 slides (1)
Puppet
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
bartzon
 

Similaire à London Hug 19/5 - Terraform in Production (20)

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data stores
 
LISA2017 Kubernetes: Hit the Ground Running
LISA2017 Kubernetes: Hit the Ground RunningLISA2017 Kubernetes: Hit the Ground Running
LISA2017 Kubernetes: Hit the Ground Running
 
Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
Puppet camp london nov 2014 slides (1)
Puppet camp london nov 2014   slides (1)Puppet camp london nov 2014   slides (1)
Puppet camp london nov 2014 slides (1)
 
Kubernetes at Spreadshirt - First steps to production
Kubernetes at Spreadshirt - First steps to productionKubernetes at Spreadshirt - First steps to production
Kubernetes at Spreadshirt - First steps to production
 
Experiences from Running Masterless Puppet - PuppetConf 2014
Experiences from Running Masterless Puppet - PuppetConf 2014Experiences from Running Masterless Puppet - PuppetConf 2014
Experiences from Running Masterless Puppet - PuppetConf 2014
 
Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Euro ht condor_alahiff
Euro ht condor_alahiffEuro ht condor_alahiff
Euro ht condor_alahiff
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Lessons learned while building Omroep.nl
Lessons learned while building Omroep.nlLessons learned while building Omroep.nl
Lessons learned while building Omroep.nl
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob KaralusDistributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons Learned
 
Benchmarking Solr Performance at Scale
Benchmarking Solr Performance at ScaleBenchmarking Solr Performance at Scale
Benchmarking Solr Performance at Scale
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 

Plus de London HashiCorp User Group (7)

London HUG 15/8/17 - Elseviers World using Nomad
London HUG 15/8/17 - Elseviers World using NomadLondon HUG 15/8/17 - Elseviers World using Nomad
London HUG 15/8/17 - Elseviers World using Nomad
 
London HUG 15/8/17 - Lifeguard
London HUG 15/8/17 - LifeguardLondon HUG 15/8/17 - Lifeguard
London HUG 15/8/17 - Lifeguard
 
London Hug 20/6 - Clustering RabbitMQ using Consul
London Hug 20/6 - Clustering RabbitMQ using ConsulLondon Hug 20/6 - Clustering RabbitMQ using Consul
London Hug 20/6 - Clustering RabbitMQ using Consul
 
London Hug 20/6 - Vault production
London Hug 20/6 - Vault productionLondon Hug 20/6 - Vault production
London Hug 20/6 - Vault production
 
London HUG 8/3 - Nomad
London HUG 8/3 - NomadLondon HUG 8/3 - Nomad
London HUG 8/3 - Nomad
 
London HUG 8/3 - Developing a (VCD) Terraform Provider
London HUG 8/3 - Developing a (VCD) Terraform ProviderLondon HUG 8/3 - Developing a (VCD) Terraform Provider
London HUG 8/3 - Developing a (VCD) Terraform Provider
 
London HUG 8/3 - JustEat - Andrew Brown / Alberto Blanco
London HUG 8/3 - JustEat - Andrew Brown / Alberto BlancoLondon HUG 8/3 - JustEat - Andrew Brown / Alberto Blanco
London HUG 8/3 - JustEat - Andrew Brown / Alberto Blanco
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

London Hug 19/5 - Terraform in Production

  • 2. • Scaleable web capacity • Scaleable load balancer capacity • Scalable service capacity • Scaleable, repeatable, self service Elasticsearch and Cassandra • Provisioning a new prod datacenter cut from 12+ months to 2. • Auto scaling, using spot capacity • Operations and Infrastructure teams: • More efficient • More agile • Providing more business value 2 Key Results
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. • Wrap Terraform up to make it harder to screw up • Makefile - easiest path - make plan / make apply
 • Use allowed_account_ids in providers (AWS specifically) 6 Lesson 1:
  • 7. 7
  • 8. • External Node Classifer • Puppetmaster calls a script, returns node definition • Create node definition from EC2 tags
 puppet::role::elasticsearch_cluster => cluster_name=reviews
 • Stop needing individual hostnames! 8 puppet ENC
  • 9. • My small contributions to the community • github.com/terraform-community-modules/tf_aws_ubuntu_ami • github.com/terraform-community-modules/ tf_aws_availability_zones
 • Modules you can reuse to stop having to hard code IDs • make + getvariables.rb pattern • We have internal versions at Yelp (usually to bake in our variables.tf.json) 9 I hate magic numbers
  • 10. • Standup update from a coworker: • Yesterday: “Learned Go” • Today: “Implemented yelpaws_instance” • Adds “ubuntu” and “region” + “account” variables to aws_instance • Looks up the AMI to use automatically • Only on initial launch, puppet converges machines after that! • https://github.com/Yelp/terraform-ami_fromhttp 10 yelpaws_instance
  • 11. 11
  • 12. • Modules • Don’t put your modules in a ../modules folder in the same repos. • Make them separate repositories, and lock SHAs/tags to avoid surprises! • Don’t deeply nest modules - pass a module everything it needs • Code • type/region-environment layout • vpc/uswest1-prod/subnets.tf • web_frontend/uswest1-prod/webs.tf • terraform.tfvars 12 Code layout
  • 13. • Build your VPC, subnets etc with terraform • Export as remote state • Pull in elsewhere - eliminate magic numbers • Much nicer solution than getvariables.rb 13 Remote state
  • 15. • nsone is an awesome DNS service! • They have a fantastic API • I wrote my own Terraform provider! • github.com/bobtfish/terraform-provider-nsone • Tie together resources from multiple regions using remote state! 15 nsone
  • 17. github.com/Yelp/terraform-provider-gitfile • Checkout git repository • Generate a file from a template • Commit + Push
 puppet/modules/zookeeper_cluster/data/cluster/xxxxx.yaml 17 gitfile
  • 18. • Puppet code: class { ‘role::elasticsearch_cluster’: cluster_name => ’reviews’, } • Hiera lookups: puppet/modules/elasticsearch_cluster/data/cluster/ reviews.yaml • Can locate the ‘data’ directory somewhere else 18 puppet data as modules
  • 19. • Spot fleet Terraform provider in use internally • ‘Coming soon’ to github 19 Spot fleet
  • 20. • puppet/modules/elasticsearch_clusters/data/cluster/reviews.yaml • Move the cluster data folder out of puppet • Add YAML for mapping of region/environment/number of nodes • Generate terraform config (as JSON) • Simple config • Directly creating ASGs • No modules • Easy to debug! • Automated cluster provisioning! (Just add Jenkins) 20 Managing Elasticsearch/Cassandra etc
  • 21. • Bad abstraction for contextual information • Which db server is the master? Does it have ‘master’ in it’s FQDN? • If it does, what happens when you promote another machine?
 • Need key => value for cattle not pets
 • Customize your monitoring system to actually tell you what’s wrong! • ‘The master DB has crashed’ vs ‘A db has crashed’ • ‘10-46-11-54 is dead’ vs ‘zookeeper::10-46-11-54 is dead` 21 Hostnames
  • 22. • Smartstack • Nerve (on host, monitors services) • Synapse (run a haproxy on lo:0) • Hacheck (cache healthcheck results to rate limit) • qdisc_tools (seamless haproxy reloads) • yocalhost: 169.254.255.254 • Reachable from the machine • Reachable from inside Docker • Each service has a fixed port 22 Service discovery
  • 23. • Terraform is really, really young. • It has some serious issues and limitations currently 23 The bad news
  • 24. • Terraform is really, really young. • It has some serious issues and limitations currently 24 The bad news The good news • It’s moving really fast • None of the things needed fundamentally change the model
  • 25. • Unfortunately, provider aliases don’t work in terraform modules • We want to provision all ‘prod’ ES clusters in one shot • So we just generate raw terraform resources, without using a module
 • Works, but it’d be nice to have more separation • ‘Make all the Elasticsearch clusters’ • ‘Make an individual Elasticsearch cluster’
 • Should be separate concerns IMO 25 Multi region
  • 26. • "Terraform is really hard to debug” • Modules make this 10x worse. • TF_LOG=1 is useful for provider authors. • NOT useful for Terraform users 26 Debugging
  • 27. output “thing_ids” { value = “${join(“,”, aws_instance.foo.*.id)}” } ${split(“,” module.foo.thing)}
 
 
 const stringListDelim = `B780FFEC-B661-4EB8-9236- A01737AD98B6` 27 Data structures
  • 28. • Lots of corner cases where they don’t work. • Some cases where they work sometimes 28 Counts and Interpolation
  • 29. • Don’t try to put your domain logic into Terraform! • Write some (simple!) classes for your domain • Make them serialize out to Terraform resources in JSON • Done! 29 KISS
  • 30. • 0.7 will fix some of my biggest complaints
 • Ability to move state • Enables refactoring existing resources into modules • Complex data structure support • No more split() join() 30 Terraform 0.7
  • 31. • Twitter: @bobtfish • IRC: #terraform (t0m) • github.com/bobtfish • github.com/Yelp • github.com/terraform-community-modules 31 Thanks