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

Testing Infrastructure in Production with Terra...

Rosemary Wang
December 18, 2019

Testing Infrastructure in Production with Terraform

Originally presented as a WWCode Cloud webinar.

Join us to hear about approaches to feature toggling, blue-green deployment, and canary testing production infrastructure. The application of these approaches differs based on the infrastructure resource and its upstream dependencies.

Rosemary Wang

December 18, 2019
Tweet

More Decks by Rosemary Wang

Other Decks in Technology

Transcript

  1. Copyright © 2019 HashiCorp Test Infrastructure in Production with Terraform

    WWCode Cloud | Dec. 18, 2019 Rosemary Wang | @joatmon08
  2. My users = developers ▪ Push and deliver code at

    any time ▪ Availability of application depends on system
  3. How do we work? ▪ Feature release vs. Continuous Delivery

    ▪ Feature branching vs. Trunk-based ▪ Mono- vs. Multi-Repository
  4. Unit / Contract Testing CODE EDITOR contains_variables(variables) { variables[_].vpc_cidr[0].value =

    "10.128.0.0/25" variables[_].region[0].value = "eu-central-1" variables[_].owner[0] } deny[msg] { not contains_variables(input.variables) msg = "Variables are not populated with expected values" }
  5. 12

  6. Feature Toggles ▪ Preserve state, if possible ▪ Inject with

    roll forward mindset ▪ Don’t write toggles at the start
  7. Feature Toggles CODE EDITOR resource "aws_instance" "example_bionic" { count =

    var.enable_new_ami ? 1 : 0 instance_type = "t2.micro" ami = data.aws_ami.ubuntu_bionic.id tags = { Terraform = "true" Owner = var.owner Has_Toggle = var.enable_new_ami } }
  8. Canary Testing ▪ Smoke test before release ▪ Easier with

    container architectures – e.g., VM images for Kubernetes worker nodes
  9. Canary Testing CODE EDITOR resource "aws_instance" "canary" { count =

    var.enable_new_network ? 1 : 0 instance_type = "t2.micro" ami = data.aws_ami.ubuntu.id vpc_security_group_ids = [aws_security_group.instances _green.id] subnet_id = aws_subnet.public_green.id tags = { Name = "${var.prefix}-canary" Owner = var.owner } }
  10. VPC (blue) 10.128.0.0/24 VPC (green) 10.128.0.0/28 APP APP APP APP

    KITCHEN INSTANCE APP APP CANARY CAN I CONNECT?
  11. Kubernetes Control Plane Kubernetes Node Group (Insecure OS) Kubernetes Node

    Group (Secure OS) INTERNAL EXTERNAL EXTERNAL EXTERNAL EXTERNAL INTERNAL INTERNAL kubectl taint nodes external=true:NoExecute
  12. A/B Testing ▪ Infrastructure that affect upstream Service Level Objectives

    ▪ Hypotheses: –Does X batch process more quickly than Y? –Does X cost more than Y?
  13. Kafka FaaS “Data Lake” versus Kafka Spark “Data Lake” APPLICATION

    APPLICATION APPLICATION APPLICATION Does Spark + Kafka architecture process faster with lower cost?
  14. Regular VM versus Network Optimized VM Does a new instance

    reduce latency? APPLICATION APPLICATION APPLICATION APPLICATION
  15. Conclusions ▪ Test in production organizes infrastructure blast radius ▪

    Risk mitigation over risk aversion ▪ “Infrastructure-as-Code” is heuristic