Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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. Patterns In Infrastructure as Code
    Takeshi Kondo / @chaspy
    Infra Study Meetup #1

    View Slide

  2. Passed

    View Slide

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

    View Slide

  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

    View Slide

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

    View Slide

  6. Infrastructure as Code in Quipper (1)
    • Infrastructure / Cloud (AWS)
    • Terraform
    • Codenize.tools (Miam, Roadworker)
    • Application Platform (Kubernetes)
    • Kube-aws
    • Server Provisioning
    • Ansible

    View Slide

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

    View Slide

  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)

    View Slide

  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)

    View Slide

  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)

    View Slide

  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

    View Slide

  12. Environment Pattern

    View Slide

  13. Environment Pattern
    Production
    Resource
    Staging
    Resource
    Staging
    Code
    Production
    Code
    Infrastructure as Code - Chapter 9. Patterns for Defining Infrastructure
    Apply Apply
    Change Change

    View Slide

  14. Environment Pattern: Why
    • To minimize blast radius
    • To test before releasing to production

    View Slide

  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

    View Slide

  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

    View Slide

  17. Scaffold Pattern

    View Slide

  18. Scaffold Pattern
    Template
    Input variable
    Code
    Generate

    View Slide

  19. Scaffold Pattern: Why
    • To make self-service easier
    • Reduce cognitive load
    Infrastructure as Code - 9.1.6 Self-Service Environments

    View Slide

  20. Scaffold Pattern: Point
    • Write a document
    • Make each program do one thing well
    https://en.wikipedia.org/wiki/Unix_philosophy

    View Slide

  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

    View Slide

  22. Create AWS Aurora resource definition

    View Slide

  23. Backup Pattern

    View Slide

  24. Backup Pattern
    Code
    Resource
    Import
    Change manually

    View Slide

  25. Backup Pattern
    Code
    Resource
    Import
    Change manually
    Apply

    View Slide

  26. Backup Pattern: Why
    • Easy to change from GUI (especially SaaS Configuration)
    • For backup
    • For greppability
    • For bulk replacement

    View Slide

  27. Backup Pattern: Point
    • Sync Interval
    • If long, it may overwrite the actual configuration

    View Slide

  28. Backup Pattern: Example
    • Datadog Dashboard
    • Datadog Monitor
    • Jenkins Configuration (SCM Sync Plugin)

    View Slide

  29. Datadog Dashboard

    View Slide

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

    View Slide

  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

    View Slide

  32. Happy (Infrastructure as) Coding

    View Slide

  33. Thank You!
    chaspy
    chaspy_
    Site Reliability Engineer

    at Quipper
    Takeshi Kondo
    Terraform-jp

    View Slide