Patterns In Infrastructure as Code

Patterns In Infrastructure as Code

93c80c388fe9d8f9df7d030549a0ff0b?s=128

Takeshi Kondo

April 24, 2020
Tweet

Transcript

  1. Patterns In Infrastructure as Code Takeshi Kondo / @chaspy Infra

    Study Meetup #1
  2. Passed

  3. Agenda • Infrastructure as Code in Quipper • Patterns in

    Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern
  4. Agenda • Infrastructure as Code in Quipper • Patterns in

    Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern • What • Why • Point • Example
  5. Agenda • Infrastructure as Code in Quipper • Patterns in

    Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern
  6. Infrastructure as Code in Quipper (1) • Infrastructure / Cloud

    (AWS) • Terraform • Codenize.tools (Miam, Roadworker) • Application Platform (Kubernetes) • Kube-aws • Server Provisioning • Ansible
  7. Infrastructure as Code in Quipper (2) • SaaS Configuration •

    Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables
  8. Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog

    • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)
  9. Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog

    • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)
  10. Infrastructure as Code in Quipper(2) • SaaS Configuration • Datadog

    • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables Terraform Codenize.tools (Barkdog) circleci-env (Internal tool)
  11. Agenda • Infrastructure as Code in Quipper • Patterns in

    Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern • What • Why • Point • Example
  12. Environment Pattern

  13. Environment Pattern Production Resource Staging Resource Staging Code Production Code

    Infrastructure as Code - Chapter 9. Patterns for Defining Infrastructure Apply Apply Change Change
  14. Environment Pattern: Why • To minimize blast radius • To

    test before releasing to production
  15. Environment Pattern: Point • Don’t Repeat Yourself • Minimize commonality

    • Keep it simple stupid • Enforcing, not communize Infrastructure as Code - 9.2.7 Approaches to Sharing Definitions
  16. Environment Pattern: Example services ᵓᴷᴷ hoge-service ᴹ ᵓᴷᴷ production ᴹ

    ᴹ ᵓᴷᴷ aurora.tf ᴹ ᴹ ᵓᴷᴷ main.tf ᴹ ᴹ ᵓᴷᴷ provider.tf ᴹ ᴹ ᵓᴷᴷ terraform.tf ᴹ ᴹ ᵓᴷᴷ terraform.tfvars ᴹ ᴹ ᵓᴷᴷ variables.tf ᴹ ᴹ ᵋᴷᴷ versions.tf ᴹ ᵋᴷᴷ staging ᴹ ᵓᴷᴷ aurora.tf ᴹ ᵓᴷᴷ main.tf ᴹ ᵓᴷᴷ provider.tf ᴹ ᵓᴷᴷ terraform.tf ᴹ ᵓᴷᴷ terraform.tfvars ᴹ ᵓᴷᴷ variables.tf ᴹ ᵋᴷᴷ versions.tf ᵋᴷᴷ modules Terraform ansible ᵋᴷᴷ ubuntu1804 ᵓᴷᴷ reverse-proxy-production ᴹ ᵓᴷᴷ goss ᴹ ᵓᴷᴷ group_vars ᴹ ᴹ ᵓᴷᴷ all.yml ᴹ ᴹ ᵓᴷᴷ development.yml ᴹ ᴹ ᵋᴷᴷ staging.yml ᴹ ᵓᴷᴷ hosts-development ᴹ ᵓᴷᴷ hosts-test ᴹ ᵓᴷᴷ roles ᴹ ᴹ ᵋᴷᴷ nginx ᴹ ᴹ ᵓᴷᴷ files ᴹ ᴹ ᵓᴷᴷ tasks ᴹ ᴹ ᵋᴷᴷ templates ᴹ ᵋᴷᴷ site.yml ᵓᴷᴷ reverse-proxy-staging ᵓᴷᴷ common-roles ᵓᴷᴷ datadog ᵓᴷᴷ td-agent Ansible
  17. Scaffold Pattern

  18. Scaffold Pattern Template Input variable Code Generate

  19. Scaffold Pattern: Why • To make self-service easier • Reduce

    cognitive load Infrastructure as Code - 9.1.6 Self-Service Environments
  20. Scaffold Pattern: Point • Write a document • Make each

    program do one thing well https://en.wikipedia.org/wiki/Unix_philosophy
  21. Scaffold Pattern: Example • Create new application with Kubernetes manifest

    • Create new resource with Terraform HCL • Create AWS Aurora resource definition • Create Datadog SLO Definition
  22. Create AWS Aurora resource definition

  23. Backup Pattern

  24. Backup Pattern Code Resource Import Change manually

  25. Backup Pattern Code Resource Import Change manually Apply

  26. Backup Pattern: Why • Easy to change from GUI (especially

    SaaS Configuration) • For backup • For greppability • For bulk replacement
  27. Backup Pattern: Point • Sync Interval • If long, it

    may overwrite the actual configuration
  28. Backup Pattern: Example • Datadog Dashboard • Datadog Monitor •

    Jenkins Configuration (SCM Sync Plugin)
  29. Datadog Dashboard

  30. Let’s Read http://shop.oreilly.com/product/0636920294382.do

  31. Special Thanks • @suzuki-shunsuke • To lead splitting Terraform state

    • To improve CI/CD pipeline • SRE graduates • To introduce of Infrastructure as Code • To build workflow with maintainability
  32. Happy (Infrastructure as) Coding

  33. Thank You! chaspy chaspy_ Site Reliability Engineer at Quipper Takeshi

    Kondo Terraform-jp