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

Taming Infrastructure Workflow at Scale (RootCo...

Anubhav Mishra
November 16, 2019

Taming Infrastructure Workflow at Scale (RootConf Hyderabad)

# Description

As more operations choices are added to your data center, whether through company acquisitions, a growing development team, or general technical debt, managing infrastructure complexity becomes a nightmare. Yet the end goal is still the same — safely deploy your application to your infrastructure. We need to tame our data centers by managing change across systems, enforcing policies, and by establishing a workflow for both developers and operations engineers to build in a collaborative environment.

This talk will discuss the problems faced in managing a modern cloud infrastructure, and how a set of innovative open source tools like Terraform can be used to tame the rising complexity curve.

Join me as I take you on a journey of exploring Infrastructure as Code techniques as we take control of our cloud infrastructure. This goal of this demo driven talk is to showcase how you can build multi-tier application infrastructure supporting multiple cloud platforms and services using IAC.

RootConf Hyderabad talk schedule link: https://hasgeek.com/rootconf/2019-hyderabad/schedule/taming-infrastructure-workflow-at-scale-LJSyh9DPfxq7p8zM23hbzn

Anubhav Mishra

November 16, 2019
Tweet

More Decks by Anubhav Mishra

Other Decks in Technology

Transcript

  1. PRIVATE CLOUD AWS AZURE GCP Run Development Connect Networking Secure

    
 Security Provision Operations HashiCorp Suite
  2. $ ssh [email protected]
 $ sudo apt-get install default-jre $ echo

    “the oracle way” $ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer $ ./setup-java.sh Terminal
  3. $ aws usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

    To see help text, you can run: aws help aws <command> help aws <command> <subcommand> help Terminal Terminal $ az /\ / \ _____ _ _ ___ _ / /\ \ |_ / | | | \'__/ _\ / ____ \ / /| |_| | | | __/ /_/ \_\/___|\__,_|_| \___|
  4. Copyright © 2019 HashiCorp @build1point0  !43 • Describe your

    infrastructure in code • Version control • Share infrastructure code • Make safe and predictable changes • Fast provisioning
  5. Copyright © 2019 HashiCorp @build1point0  Questions !44 How Do

    We Provision Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)
  6. Copyright © 2019 HashiCorp @build1point0  Questions !45 How Do

    We Manage the Lifecycle of Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)
  7. Copyright © 2019 HashiCorp @build1point0  Questions !46 How Do

    We Enforce Policies Across the Resources? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)
  8. Copyright © 2019 HashiCorp @build1point0  Questions !47 How Do

    We Automate and Share the Configurations? • Compute (Cloud Servers) • Network (VPCs, ACLs, Firewalls) • Storage (Databases, Object Stores)
  9. Copyright © 2019 HashiCorp @build1point0  Goal !50 Provide a

    Unified Workflow Using Infrastructure as Code to Iterate Over Infrastructure Safely that is Capable of Provisioning Anything Anywhere.
  10. Copyright © 2019 HashiCorp @build1point0  !52 Terminal resource "azurerm_virtual_machine"

    "web" { storage_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "16.04-LTS" version = "latest" } } resource "aws_instance" "web" { ami = "ami-b123125" } main.tf
  11. Copyright © 2019 HashiCorp @build1point0  !53 Terminal resource "azurerm_public_ip"

    "web" { name = "webserver-ip" location = "West US" resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  12. Copyright © 2019 HashiCorp @build1point0  !54 Terminal resource "azurerm_public_ip"

    "web" { name = "webserver-ip" location = "West US" resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "dnsimple_record" "hello" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  13. Copyright © 2019 HashiCorp @build1point0  !55 Terminal resource "cloudflare_page_rule"

    "www" { # ... } resource "fastly_service_v1" "myservice" { name = "myawesometestservice" # ... } main.tf
  14. Copyright © 2019 HashiCorp @build1point0  !56 Terminal resource "github_membership"

    "membership_for_some_user" { username = "admin" role = "owner" } resource "gitlab_project" "example" { name = "example" description = "My awesome codebase" visibility_level = "public" } main.tf
  15. Copyright © 2019 HashiCorp @build1point0  !59 Amazon BitBucket CenturyLink

    Cloud CloudFlare CloudStack Cobbler Consul Datadog DigitalOcean DNSMadeEasy DNSimple Docker Dyn GitHub Fastly Google Heroku Librato Microsoft Azure MySQL OpenStack Packet PostgreSQL SoftLayer UltraDNS VMware Sphere and more...
  16. Copyright © 2019 HashiCorp @build1point0  !59 Amazon BitBucket CenturyLink

    Cloud CloudFlare CloudStack Cobbler Consul Datadog DigitalOcean DNSMadeEasy DNSimple Docker Dyn GitHub Fastly Google Heroku Librato Microsoft Azure MySQL OpenStack Packet PostgreSQL SoftLayer UltraDNS VMware Sphere and more...
  17. Copyright © 2019 HashiCorp @build1point0  !59 Amazon BitBucket CenturyLink

    Cloud CloudFlare CloudStack Cobbler Consul Datadog DigitalOcean DNSMadeEasy DNSimple Docker Dyn GitHub Fastly Google Heroku Librato Microsoft Azure MySQL OpenStack Packet PostgreSQL SoftLayer UltraDNS VMware Sphere and more... 100s Terraform Providers
  18. Copyright © 2019 HashiCorp @build1point0  !59 Amazon BitBucket CenturyLink

    Cloud CloudFlare CloudStack Cobbler Consul Datadog DigitalOcean DNSMadeEasy DNSimple Docker Dyn GitHub Fastly Google Heroku Librato Microsoft Azure MySQL OpenStack Packet PostgreSQL SoftLayer UltraDNS VMware Sphere and more...
  19. Copyright © 2019 HashiCorp @build1point0  Terraform Usage !67 •

    Contributors ~4600 • Downloads ~300,000/month (unique) • Modules ~2000
  20. Copyright © 2019 HashiCorp @build1point0  Goal !68 Provide a

    Unified Workflow Using Infrastructure as Code to Iterate Over Infrastructure Safely that is Capable of Provisioning Anything Anywhere.
  21. Copyright © 2019 HashiCorp @build1point0  Goal !69 Provide a

    Unified Workflow Using Infrastructure as Code to Iterate Over Infrastructure Safely that is Capable of Provisioning Anything Anywhere.
  22. Copyright © 2019 HashiCorp @build1point0  !71 Terminal resource "azurerm_public_ip"

    "web" { resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "azurerm_network_interface" "web" { resource_group_name = "webserver-rg" ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { offer = "UbuntuServer" ..... } } resource "dnsimple_record" "web" { domain = "example.com" name = "webs" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  23. Copyright © 2019 HashiCorp @build1point0  !72 Terminal resource "azurerm_public_ip"

    "web" { resource_group_name = "webserver-rg" public_ip_address_allocation = "static" } resource "azurerm_network_interface" "web" { resource_group_name = "webserver-rg" ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { offer = "UbuntuServer" ..... } } resource "dnsimple_record" "web" { domain = "example.com" name = "webs" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  24. Copyright © 2019 HashiCorp @build1point0  !74 “Shows You What

    Will Happen Before It Actually Happens” TERRAFORM PLAN Anubhav Mishra Rootconf Hyderabad 2019
  25. Copyright © 2019 HashiCorp @build1point0  !75 Terminal + azurerm_public_ip.web

    ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: <computed> domain: "example.com" domain_id: <computed> hostname: <computed> name: "test" priority: <computed> ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell
  26. Copyright © 2019 HashiCorp @build1point0  !76 Terminal + azurerm_public_ip.web

    ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: <computed> domain: "example.com" domain_id: <computed> hostname: <computed> name: "test" priority: <computed> ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell
  27. Copyright © 2019 HashiCorp @build1point0  !77 Terminal + azurerm_public_ip.web

    ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: <computed> domain: "example.com" domain_id: <computed> hostname: <computed> name: "test" priority: <computed> ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell
  28. Copyright © 2019 HashiCorp @build1point0  !78 Terminal + azurerm_public_ip.web

    ..... + azurerm_network_interface.web ..... + azurerm_virtual_machine.webserver ..... + dnsimple_record.hello id: <computed> domain: "example.com" domain_id: <computed> hostname: <computed> name: "test" priority: <computed> ttl: "3600" type: "A" value: "${azurerm_public_ip.web.ip_address}" shell
  29. Copyright © 2019 HashiCorp @anubhavm  !83 Map of Real

    World Resources to Your Configuration. TERRAFORM STATE
  30. Copyright © 2019 HashiCorp @anubhavm  !84 Terminal { "version":

    3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate
  31. Copyright © 2019 HashiCorp @anubhavm  !85 Terminal { "version":

    3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate
  32. Copyright © 2019 HashiCorp @anubhavm  !85 Terminal { "version":

    3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate
  33. Copyright © 2019 HashiCorp @anubhavm  !85 Terminal { "version":

    3, "terraform_version": "0.11.5", "serial": 4, "lineage": "af985fb6-6e75-66bc-984a-7635ea4249c7", "modules": [ { "path": [ "root" ], "outputs": {}, "resources": { "azurerm_resource_group.default": { "type": "azurerm_resource_group", "depends_on": [], "primary": { "id": "", }, }, "deposed": [], "provider": "provider.azurerm" } }, "depends_on": [] }, terraform.tfstate Storage: Terraform Cloud, file, consul, azurerm, s3, gcs, etc.
  34. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) FOO SERVICE (EC2 instances, ASGs…..)
  35. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) FOO SERVICE (EC2 instances, ASGs…..)
  36. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..)
  37. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT
  38. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING
  39. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING PRODUCTION
  40. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING PRODUCTION DEVELOPMENT
  41. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING PRODUCTION DEVELOPMENT STAGING
  42. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING PRODUCTION DEVELOPMENT STAGING Terraform Workspaces
  43. Copyright © 2019 HashiCorp @anubhavm  !87 TERRAFORM STATE ORGANIZATION

    NETWORKING (VPCs, ACLs, Routing Table..) BAR SERVICE (Lambda, RDS instances…..) FOO SERVICE (EC2 instances, ASGs…..) DEVELOPMENT STAGING PRODUCTION DEVELOPMENT STAGING Terraform Workspaces }
  44. Copyright © 2019 HashiCorp @build1point0  !90 Terminal resource "azurerm_public_ip"

    "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = 1 network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "UbuntuServer" sku = "16.04-LTS" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  45. Copyright © 2019 HashiCorp @build1point0  !91 Terminal resource "azurerm_public_ip"

    "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = "${var.count}" network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "${var.os_name}" sku = "${var.sku}" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  46. Copyright © 2019 HashiCorp @build1point0  !92 Terminal resource "azurerm_public_ip"

    "web" { ..... } resource "azurerm_network_interface" "web" { ip_configuration { ..... public_ip_address_id = "${azurerm_public_ip.web.id}" } } resource "azurerm_virtual_machine" "web" { count = "${var.count}" network_interface_ids = ["${azurerm_network_interface.web.id}"] storage_image_reference { publisher = "Canonical" offer = "${var.os_name}" sku = “${var.sku}" version = "latest" } } resource "dnsimple_record" "web" { domain = "example.com" name = "test" value = "${azurerm_public_ip.web.ip_address}" type = "A" } main.tf
  47. Copyright © 2019 HashiCorp @build1point0  !93 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf
  48. Copyright © 2019 HashiCorp @build1point0  !94 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf Inputs Outputs
  49. Copyright © 2019 HashiCorp @build1point0  !96 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf
  50. Copyright © 2019 HashiCorp @build1point0  !97 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER
  51. Copyright © 2019 HashiCorp @build1point0  !98 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER SOFTWARE ENGINEER
  52. Copyright © 2019 HashiCorp @build1point0  !99 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf OPERATIONS ENGINEER SOFTWARE ENGINEER WEBSERVERS
  53. Copyright © 2019 HashiCorp @build1point0  !100 Terminal module "webserver"

    { source = "mishracorp/webserver?ref=v1.2.0" count = 10 os_name = "UbuntuServer" environment = "development" service_name = "profile" contact = "Anubhav Mishra" } main.tf
  54. Copyright © 2019 HashiCorp @build1point0  !101 Terminal module "webserver"

    { source = "mishracorp/webserver?ref=v1.2.0" count = 10 os_name = "UbuntuServer" environment = "development" service_name = "profile" contact = "Anubhav Mishra" } main.tf Module Versioning
  55. Copyright © 2019 HashiCorp @build1point0  !102 Terminal module "webserver"

    { source = "mishracorp/webserver" count = 10 os_name = "UbuntuServer" } main.tf Terminal module "webserver" { source = “mishracorp/mysql- database“ read_replica_count = 10 } main.tf Terminal module "webserver" { source = “mishracorp/pub-sub” } main.tf Terminal module "webserver" { source = “mishracorp/ autoscaling-group” min_count = 10 } main.tf Terminal module "webserver" { source = “mishracorp/ kubernetes" nodes = 10 } main.tf
  56. Copyright © 2019 HashiCorp @build1point0  !103 CORE MODULES SERVICE

    MODULES OPERATIONS ENGINEER PLATFORM ENGINEER PRODUCERS
  57. Copyright © 2019 HashiCorp @build1point0  !103 CORE MODULES SERVICE

    MODULES OPERATIONS ENGINEER PLATFORM ENGINEER PRODUCERS
  58. Copyright © 2019 HashiCorp @build1point0  !103 CORE MODULES SERVICE

    MODULES OPERATIONS ENGINEER PLATFORM ENGINEER PRODUCERS
  59. Copyright © 2019 HashiCorp @build1point0  !103 CORE MODULES SERVICE

    MODULES OPERATIONS ENGINEER PLATFORM ENGINEER PRODUCERS CONSUMERS