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

Golden Images and How To Create Them

Golden Images and How To Create Them

Hashitalks: Vietnam 2022

Tommy Nguyen

May 05, 2022
Tweet

More Decks by Tommy Nguyen

Other Decks in Technology

Transcript

  1. Liftoff + Vungle (LV) • Liftoff is a leading growth

    acceleration platform for the mobile industry, helping advertisers, publishers and game developers scale revenue growth with solutions to market and monetize mobile apps. • With a suite of solutions including Vungle, JetFuel, GameRefinery and Tresensa, Liftoff supports over 6,600 mobile businesses across 74 countries, including gaming, social, finance, ecommerce, entertainment and more. • Liftoff is proud to be a long-term partner to leading advertisers and app publishers since 2012. Headquartered in Redwood City, CA, Liftoff has a growing global presence with offices around the world.
  2. Tommy Nguyen • https://tuannvm.com • CKA / CKAD / CKS,

    Kubernetes enthusiast • Make use of Hashicorp tools to make life easier Lead Production Engineer Liftoff + Vungle | Engineering | Singapore
  3. A golden image is a template for a virtual machine

    (VM), virtual desktop, server or hard disk drive. A golden image may also be referred to as a clone image, master image or base image. Reference
  4. Engineers waste all their time inventing ways to make the

    most money in the quickest, most efficient way possible. And then when they figure it out, they optimize the process.” Raul Perez
  5. Now

  6. λ packer % tree -L 2 . ├── base.pkr.hcl ##

    → Base image ├── kafka.pkr.hcl ## → Build Kafka image on top of base image ├── plugins.pkr.hcl ## → Required 3rd plugins ├── terraform.tf ## → Unit testing with terraform └── variables.pkr.hcl ## → Variables required by building process
  7. # Based Ubuntu with ansible installed source "amazon-ebs" "ubuntu_ansible" {

    ami_name = "ubuntu-ansible" instance_type = var.instance_type region = var.aws_region source_ami_filter { filters = { name = "ubuntu/images/*ubuntu-tommial-22.04-amd64-server-*" } owners = ["099720109477"] } ssh_username = var.ssh_username } build { name = "ubuntu-ansible" sources = [ "source.amazon-ebs.ubuntu_ansible" ] provisioner "shell" { inline = [ "sudo apt update", "sudo apt install ansible -y", ] } }
  8. ## Use Ansible source "amazon-ebs" "kafka" { ami_name = "kafka-${var.environment}"

    iam_instance_profile = var.iam_instance_profile instance_type = var.instance_type region = var.aws_region ## Additional volumes dynamic "launch_block_device_mappings" { for_each = var.volumes content { delete_on_termination = var.delete_on_termination encrypted = var.encrypted iops = var.iops throughput = var.throughput volume_type = var.volume_type device_name = launch_block_device_mappings.value volume_size = var.volume_size } } source_ami_filter { [REDACTED] } ssh_username = var.ssh_username } build { name = "kafka" sources = [ "source.amazon-ebs.kafka" ] provisioner "shell" { inline = [ [REDACTED] ] } }
  9. locals { ## TODO: Use vault instead of secret manager

    token = aws_secretsmanager("key1", "value1") vault_pass = aws_secretsmanager("key2", "value2") tags = { Environment = upper(var.environment) Module = var.app } } variable "app" { default = "Kafka" } [REDACTED]
  10. It’s all about the statistics Type of Provisioning Time Manual

    1+ hour / instance With configuration management (Ansible) 20+ mins / instance With Packer (building time excluded) 1+ mins / instance
  11. Senior Software Engineer, Production Engineering (Singapore) Staff Software Engineer, Production

    Engineering (Worldwide) Senior Software Engineer, Production Engineering (Beijing) Staff Software Engineer, Production Engineering (Singapore)