Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Patterns In Infrastructure as Code

Patterns In Infrastructure as Code

Takeshi Kondo

April 24, 2020
Tweet

More Decks by Takeshi Kondo

Other Decks in Technology

Transcript

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

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

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

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

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

    Datadog • Dashboard • SLO • Monitor • Pingdom • Deadman’s snitch • CircleCI • Environment Variables
  6. 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)
  7. 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)
  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. Agenda • Infrastructure as Code in Quipper • Patterns in

    Infrastructure as Code 1. Environment Pattern 2. Scaffold Pattern 3. Backup Pattern • What • Why • Point • Example
  10. Environment Pattern Production Resource Staging Resource Staging Code Production Code

    Infrastructure as Code - Chapter 9. Patterns for Defining Infrastructure Apply Apply Change Change
  11. 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
  12. 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
  13. Scaffold Pattern: Why • To make self-service easier • Reduce

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

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

    • Create new resource with Terraform HCL • Create AWS Aurora resource definition • Create Datadog SLO Definition
  16. Backup Pattern: Why • Easy to change from GUI (especially

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

    may overwrite the actual configuration
  18. 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