Slide 1

Slide 1 text

Terraform ❤ Vungle Tommy Nguyen Staff Site Reliability Engineer @ Vungle https://tuannvm.com

Slide 2

Slide 2 text

Agenda - Vungle Introduction - Infrastructure Overview - IaC - Terraform 101 - Terraform @ Vungle - Cluster Prerequisites - Cluster Provisioning - Demo - Q & A - Conclusion

Slide 3

Slide 3 text

Who Are We?

Slide 4

Slide 4 text

We Are Vungle Performance Ad Network Vungle directly connects premium global advertisers Advertisers Acquire high quality users with high performance outcomes (installs) Publishers Supply inventory of users with high performance revenue with publishers ad inventory – across brands and gaming audiences

Slide 5

Slide 5 text

/ 5 San Francisco London Berlin Singapore Beijing Seoul Tokyo 87% out of the top 100 apps have seen success with Vungle 60K total apps trust Vungle to monetize their apps 2B unique devices experience high-quality Vungle ads every month 150+ countries experience Vungle ads every day New York

Slide 6

Slide 6 text

Robust Data Vungle has always been at the forefront of performance advertising, setting industry standards since the first smartphones came to market. Today, Vungle touches a third of all smartphones on the planet and serves 5 billion ads every month.

Slide 7

Slide 7 text

Infrastructure Overview

Slide 8

Slide 8 text

...

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Infrastructure as Code (IaC)

Slide 13

Slide 13 text

The Benefit of Adapting IaC - Faster speed and consistency - Efficient software development lifecycle - Reduced operation overhead

Slide 14

Slide 14 text

CODE EDITOR . ├── README.md ├── infra │ ├── secrets │ └── terraform ├── ops │ ├── helm │ ├── terraform │ └── ... ├── pull_request_template.md └── src ├── mongo-exporter ├── redis-exporter ├── lib ├── metrics-explorer └── ...

Slide 15

Slide 15 text

Terraform 101

Slide 16

Slide 16 text

What is it? - Terraform codifies cloud APIs into declarative configuration files. - Same configuration language to work with all cloud providers.

Slide 17

Slide 17 text

Write Plan Apply

Slide 18

Slide 18 text

Code Editor # main.tf resource "aws_instance" "web" { ami = "ami-005e54dee72cc1d00" instance_type = "t3.micro" tags = { Name = "HelloWorld" } }

Slide 19

Slide 19 text

Terminal $ terraform apply An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: + aws_instance.web id: ami: "ami-032fb460" # ... aws_instance.web: Creating... ami: "" => "ami-032fb460" associate_public_ip_address: "" => "" # … aws_instance.web: Still creating... (10s elapsed) aws_instance.web: Still creating... (20s elapsed) aws_instance.web: Creation complete after 21s (ID: i-062e80b6d9f079a17) Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Slide 20

Slide 20 text

Terraform @ Vungle

Slide 21

Slide 21 text

AWS - Manage non-kubernetes infrastructure - VPC - Dynamodb - S3 - Route53 - ...

Slide 22

Slide 22 text

Other Providers - Not just AWS / GCP, Terraform also supports the wide range of providers - Infrastructure - Content Delivery Network - Monitoring

Slide 23

Slide 23 text

Custom Providers - SDK / Library to write provider for custom usage.

Slide 24

Slide 24 text

Cluster Prerequisites

Slide 25

Slide 25 text

Network - VPC - IP address planning (how many subnets, how big it is,...) - VPC Peering

Slide 26

Slide 26 text

Naming Convention - Make sure that related resources have related name / tag - Easier to do cost management - Easier to clean up - Easier to audit

Slide 27

Slide 27 text

Kubernetes Cluster Provisioning

Slide 28

Slide 28 text

Overview - Amazon EKS is the hosted Kubernetes solution in Amazon Web Services - EKS makes it easy to standardize operations across every environment

Slide 29

Slide 29 text

Approaches - Via console - Via command-line tool - Or via Terraform

Slide 30

Slide 30 text

Console

Slide 31

Slide 31 text

Terminal $ eksctl create cluster --name my-cluster \ --region us-west-2 --with-oidc \ --ssh-access --ssh-public-key --managed $ eksctl create cluster -f cluster.yaml ``` apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: basic-cluster region: eu-north-1 nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 10 - name: ng-2 instanceType: m5.xlarge desiredCapacity: 2 ```

Slide 32

Slide 32 text

Code Editor module "eks" { source = "../../modules/eks" namespace = "eks" environment = "stage" name = "1a" region = "us-east-1" vpc_id = data.aws_vpc.self.vpc_id vpc_cidr = data.aws_vpc.self.vpc_id public_subnets = { "eks-stage-1a-public-1" = { cidr_block = "10.x.x.x/24" availability_zone = "us-east-1a" tag_enabled = true }, } private_subnets = { "eks-stage-1a-private-1" = { cidr_block = "10.x.x.x/24" availability_zone = "us-east-1a" nat_to = "eks-stage-1a-public-1" }, } }

Slide 33

Slide 33 text

Terminal λ eks % tree . ├── README.md ├── cluster.tf ├── iam.tf ├── logging.tf ├── main.tf ├── spotinst.tf ├── terraform.tf ├── variables.tf └── network.tf

Slide 34

Slide 34 text

Terminal λ eks_addon % tree . ├── README.md ├── aws_auth.tf ├── configs ├── helm.tf ├── jobs.tf ├── main.tf ├── metric-server.tf ├── nginx-ingress.tf ├── rbac.tf ├── spotinst.tf ├── terraform.tf └── variables.tf

Slide 35

Slide 35 text

Demo

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Q & A

Slide 38

Slide 38 text

Love challenges? Ping me!