SlideShare a Scribd company logo
1 of 26
Download to read offline
Evolution of Software Deployment
● Big, expensive mainframes with few owners
● Server rooms for many and data centers for few
● Data center colocation - first generation rent a server, still expensive
● Virtual machine, shared nodes
● Cloud providers eg. AWS and GCP
● Instead of managing hardware, tools become more software-based
● Now sysadmins are writing more software code ← Devops
Typical Cloud Setup
● Set up network
○ Virtual private cloud
○ Set up subnets and other networking tasks
○ Set up firewall rules
● Set up users and access
○ Users - real users and service accounts
○ Policies and access control
● Set up resources
○ Computation
○ Storage
○ Database
● Integrate
● Test
It’s time consuming and error prone
Infrastructure as Code (IaC)
● Scripts - IaC is nothing new, scripts provide some semi-automation. Scripts
actually work well in ad hoc contexts
● Server templating tools - Docker and Packer are good tools that enable us to
define unit deployments for applications
● Cluster orchestration tools - Today we deploy multiple apps and services
running on multiple resources. Kubernetes is a good way to orchestrate such
deployment, make efficient use of resources, and scale
● Resource provisioning tools - These tools like Terraform is great for creating
the actual resources for hosting the apps and services
Reference: Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
Heterogeneous Solutions
● Tools are designed for specifically for one of abstract layers
● They complement each other
● The diagram shows Docker, Kubernetes, and Terraform as IaC tools as a
fullstack for devops. But you can mix and match any other tools
● Use the right combination that serves your needs
● Use Terraform to manage multiple Cloud networks eg. AWS and GCP
● Use Terraform and Docker or Packer
○ Terraform a GKE cluster to deploy Docker containers
○ Terraform GCE instances to deploy Packer images
Today we focus on Terraform - a IaC tool for
provisioning Cloud resources
What is Terraform?
Reference: Terraform: Some Introduction
Benefits of Terraform
● Documentation - Codify the infrastructure as code. As least it’s much easier to
understand human-readable code
● Version control - Because the infrastructure is now code, you do versioning
allow you to quickly revert back to a specific version
● Automation - You can easily deploy the code using CI/CD or other tools
○ Faster - this is no longer a manual process
○ Safer - validations against your code: compile the code, check against
existing infrastructure state, code review, tests
● Reusability - Certain configurations, resources and repeatable provisioning
processes can be reused through your or external modules and plug-ins
GCP Connection
● Primary ways you interface with GCP
○ Admin console
○ gcloud CLI tool ← programmatic interface
○ GCP SDK ← programmatic interface
○ Terraform ← programmatic interface
● All programmatic interface requires gcloud setup
○ gcloud init - set up the project and other key configurations
○ gcloud auth - identify who you are and consequently your access
Terraform Code
● Terraform code is declarative - declare the state you desire in the
infrastructure and Terraform will figure it out how to get there
● Hence Terraform needs to know the current state. State management is a big
part of Terraform
● The Terraform constructs, here are the key ones:
○ Providers
○ Resources
○ Variables (local, input, output)
○ Expressions
○ Functions
○ Others - check out Terraform 0.12 language
// main.tf - a simple Terraform code
provider "google" {
region = var.region
project = var.project_id
}
resource "google_compute_instance" "web" {
name = "web"
machine_type = "n1-standard-1"
zone = "us-west1-a"
disk {
image = "ubuntu-os-cloud/ubuntu-1404-trusty-v20160602"
}
network_interface {
network = "default"
}
}
// variables.tf - inputs to the Terraform template
variable "region" {
description = "The region where the instance will be deployed."
type = string
default = "us-west1"
}
variable "region_zone" {
description = "The zone where the instance will be deployed."
type = string
default = "us-west1-a"
}
variable "project_id" {
description = "The ID of the GCP project."
type = string
}
// outputs.tf - outputs (state) after the resource has been deployed
// You can have a terraform.tfvars that contains all the input
// values
output "instance_id" {
description = "The unique identifier of the deployed instance."
type = string
value = google_compute_instance.web.instance_id
}
Terraform Commands
$ terraform init
$ terraform plan
$ terraform apply # Actual deployment to the Cloud
$ terraform destroy
You will see the following the following created:
- .terraform - downloaded dependencies eg. modules, providers
- *.tfstate - the current state of the infrastructure, basically a tree of the
resources
Demo
Let’s run the Terraform code
(might take a while)
See Github repository:
https://github.com/cybersamx/terraform-gke
Connect to your GCP and Start Terraforming
● Launch your shell
$ export PROJECT_ID='<YOUR_PROJECT_ID>'
$ gcloud auth revoke # Log out
$ gcloud init # Initialize with a project ID
$ gcloud auth login
$ # If the previous command doesn’t work try the following
$ gcloud auth application-default login
● Now you are now connected to GCP, you can run terraform with the right
access and authorization
● Go to the terraform project and the /dev folder and run the following
$ terraform init
$ terraform plan
$ terraform apply
GitOps
● Because Terraform is code, you can use existing workflows and tools for development
and release
● Leverage existing workflow and tools with slight variation
● Collaborate as much as possible yet isolate as possible
● Break the Terraform configuration into multiple sets of files
● Versioning - Use git to store your Terraform code
● Isolate your environments through directories
○ Folder: dev, staging, prod
○ Branch: dev, staging, master
○ Environment: dev, staging, prod
● Start off with dev, build, test, and if it passes the current env promote to the next env
● Each environment folder has its own sets of configurations
Reference: GitOps and Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
Terraform Project Layout
● dev
○ network
○ services
■ frontend-app
■ backend-app
● variables.tf
● outputs.tf
● Main.tf
○ data-storage
● staging
● prod
● global
● modules
Reference: Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
Let’s check the Terraform run and deploy
containers to the new k8s cluster
Deploying Containers to Cluster
● Now that we have set up a cluster and resources, let’s deploy an application
● We will be using a Hello World app example on Kubernetes home page
● First we need to set up kubectl for you to connect to the cluster
$ gcloud container clusters get-credentials dev-cluster --region us-west1
$ kubectl config current-context
$ gke_<PROJECT_ID>_us-west1_dev-cluster
$ # You should see the above output
$ # Query the cluster
$ kubectl get node
NAME READY UP-TO-DATE AVAILABLE AGE
Troubleshooting Tips
● Start off a project interactively, get the gcloud equivalent, and then Terraform
● Set TF_LOG=TRACE
● Remove .terraform directory (back it up first) and rerun terraform init
● Run terraform console to play around with expressions
Terraforming your Infrastructure on GCP

More Related Content

What's hot

Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowAnton Babenko
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Amazon Web Services
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practicesAnton Babenko
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To TerraformSasitha Iresh
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 
Best Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with TerraformBest Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with TerraformDevOps.com
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Edureka!
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistenceJanakiram MSV
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...
Containerising the Mule Runtime with Kubernetes & From Zero to Batch  : MuleS...Containerising the Mule Runtime with Kubernetes & From Zero to Batch  : MuleS...
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...Angel Alberici
 
Working with Terraform on Azure
Working with Terraform on AzureWorking with Terraform on Azure
Working with Terraform on Azuretombuildsstuff
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introductionJason Vance
 

What's hot (20)

Building infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps KrakowBuilding infrastructure as code using Terraform - DevOps Krakow
Building infrastructure as code using Terraform - DevOps Krakow
 
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
Using HashiCorp’s Terraform to build your infrastructure on AWS - Pop-up Loft...
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Terraform modules and (some of) best practices
Terraform modules and (some of) best practicesTerraform modules and (some of) best practices
Terraform modules and (some of) best practices
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Terraform
TerraformTerraform
Terraform
 
Best Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with TerraformBest Practices of Infrastructure as Code with Terraform
Best Practices of Infrastructure as Code with Terraform
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Terraform
TerraformTerraform
Terraform
 
Terraform
TerraformTerraform
Terraform
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistence
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...
Containerising the Mule Runtime with Kubernetes & From Zero to Batch  : MuleS...Containerising the Mule Runtime with Kubernetes & From Zero to Batch  : MuleS...
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...
 
Working with Terraform on Azure
Working with Terraform on AzureWorking with Terraform on Azure
Working with Terraform on Azure
 
Terraform introduction
Terraform introductionTerraform introduction
Terraform introduction
 

Similar to Terraforming your Infrastructure on GCP

Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfssuser705051
 
Scaling terraform
Scaling terraformScaling terraform
Scaling terraformPaolo Tonin
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataInfluxData
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3sHaggai Philip Zagury
 
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...Haggai Philip Zagury
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in ContainerizationRyan Hunter
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotClouddaoswald
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerEric Smalling
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tipsSamuel Chow
 
The benefits of running Spark on your own Docker
The benefits of running Spark on your own DockerThe benefits of running Spark on your own Docker
The benefits of running Spark on your own DockerItai Yaffe
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1Ruslan Meshenberg
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and HerokuTapio Rautonen
 
Introduction to Apache Airflow
Introduction to Apache AirflowIntroduction to Apache Airflow
Introduction to Apache Airflowmutt_data
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production Hung Lin
 
Making Service Deployments to AWS a breeze with Nova
Making Service Deployments to AWS a breeze with NovaMaking Service Deployments to AWS a breeze with Nova
Making Service Deployments to AWS a breeze with NovaGregor Heine
 
Webinar: Enterprise Blockchain Radically Simplified with Truffle and Kaleido
Webinar: Enterprise Blockchain Radically Simplified with Truffle and KaleidoWebinar: Enterprise Blockchain Radically Simplified with Truffle and Kaleido
Webinar: Enterprise Blockchain Radically Simplified with Truffle and KaleidoKaleido
 

Similar to Terraforming your Infrastructure on GCP (20)

Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
Scaling terraform
Scaling terraformScaling terraform
Scaling terraform
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
 
Netty training
Netty trainingNetty training
Netty training
 
Netty training
Netty trainingNetty training
Netty training
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in Containerization
 
Introduction to IAC and Terraform
Introduction to IAC and Terraform Introduction to IAC and Terraform
Introduction to IAC and Terraform
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
The benefits of running Spark on your own Docker
The benefits of running Spark on your own DockerThe benefits of running Spark on your own Docker
The benefits of running Spark on your own Docker
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and Heroku
 
Introduction to Apache Airflow
Introduction to Apache AirflowIntroduction to Apache Airflow
Introduction to Apache Airflow
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
 
Making Service Deployments to AWS a breeze with Nova
Making Service Deployments to AWS a breeze with NovaMaking Service Deployments to AWS a breeze with Nova
Making Service Deployments to AWS a breeze with Nova
 
Webinar: Enterprise Blockchain Radically Simplified with Truffle and Kaleido
Webinar: Enterprise Blockchain Radically Simplified with Truffle and KaleidoWebinar: Enterprise Blockchain Radically Simplified with Truffle and Kaleido
Webinar: Enterprise Blockchain Radically Simplified with Truffle and Kaleido
 

More from Samuel Chow

GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the CloudGCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the CloudSamuel Chow
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudDocker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudSamuel Chow
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and MicroserviceSamuel Chow
 
UI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesUI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesSamuel Chow
 
Mobile Analytics
Mobile AnalyticsMobile Analytics
Mobile AnalyticsSamuel Chow
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release ManagementSamuel Chow
 
Frisbee Thrower Prototype
Frisbee Thrower PrototypeFrisbee Thrower Prototype
Frisbee Thrower PrototypeSamuel Chow
 
Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)Samuel Chow
 

More from Samuel Chow (8)

GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the CloudGCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudDocker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
UI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best PracticesUI Design - Lessons Learned, Principles, and Best Practices
UI Design - Lessons Learned, Principles, and Best Practices
 
Mobile Analytics
Mobile AnalyticsMobile Analytics
Mobile Analytics
 
iOS Release Management
iOS Release ManagementiOS Release Management
iOS Release Management
 
Frisbee Thrower Prototype
Frisbee Thrower PrototypeFrisbee Thrower Prototype
Frisbee Thrower Prototype
 
Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)Frisbee Thrower Concepts (Part 1)
Frisbee Thrower Concepts (Part 1)
 

Recently uploaded

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 

Terraforming your Infrastructure on GCP

  • 1.
  • 2. Evolution of Software Deployment ● Big, expensive mainframes with few owners ● Server rooms for many and data centers for few ● Data center colocation - first generation rent a server, still expensive ● Virtual machine, shared nodes ● Cloud providers eg. AWS and GCP ● Instead of managing hardware, tools become more software-based ● Now sysadmins are writing more software code ← Devops
  • 3. Typical Cloud Setup ● Set up network ○ Virtual private cloud ○ Set up subnets and other networking tasks ○ Set up firewall rules ● Set up users and access ○ Users - real users and service accounts ○ Policies and access control ● Set up resources ○ Computation ○ Storage ○ Database ● Integrate ● Test
  • 4. It’s time consuming and error prone
  • 5. Infrastructure as Code (IaC) ● Scripts - IaC is nothing new, scripts provide some semi-automation. Scripts actually work well in ad hoc contexts ● Server templating tools - Docker and Packer are good tools that enable us to define unit deployments for applications ● Cluster orchestration tools - Today we deploy multiple apps and services running on multiple resources. Kubernetes is a good way to orchestrate such deployment, make efficient use of resources, and scale ● Resource provisioning tools - These tools like Terraform is great for creating the actual resources for hosting the apps and services Reference: Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
  • 6.
  • 7. Heterogeneous Solutions ● Tools are designed for specifically for one of abstract layers ● They complement each other ● The diagram shows Docker, Kubernetes, and Terraform as IaC tools as a fullstack for devops. But you can mix and match any other tools ● Use the right combination that serves your needs ● Use Terraform to manage multiple Cloud networks eg. AWS and GCP ● Use Terraform and Docker or Packer ○ Terraform a GKE cluster to deploy Docker containers ○ Terraform GCE instances to deploy Packer images
  • 8. Today we focus on Terraform - a IaC tool for provisioning Cloud resources
  • 9. What is Terraform? Reference: Terraform: Some Introduction
  • 10. Benefits of Terraform ● Documentation - Codify the infrastructure as code. As least it’s much easier to understand human-readable code ● Version control - Because the infrastructure is now code, you do versioning allow you to quickly revert back to a specific version ● Automation - You can easily deploy the code using CI/CD or other tools ○ Faster - this is no longer a manual process ○ Safer - validations against your code: compile the code, check against existing infrastructure state, code review, tests ● Reusability - Certain configurations, resources and repeatable provisioning processes can be reused through your or external modules and plug-ins
  • 11. GCP Connection ● Primary ways you interface with GCP ○ Admin console ○ gcloud CLI tool ← programmatic interface ○ GCP SDK ← programmatic interface ○ Terraform ← programmatic interface ● All programmatic interface requires gcloud setup ○ gcloud init - set up the project and other key configurations ○ gcloud auth - identify who you are and consequently your access
  • 12. Terraform Code ● Terraform code is declarative - declare the state you desire in the infrastructure and Terraform will figure it out how to get there ● Hence Terraform needs to know the current state. State management is a big part of Terraform ● The Terraform constructs, here are the key ones: ○ Providers ○ Resources ○ Variables (local, input, output) ○ Expressions ○ Functions ○ Others - check out Terraform 0.12 language
  • 13.
  • 14. // main.tf - a simple Terraform code provider "google" { region = var.region project = var.project_id } resource "google_compute_instance" "web" { name = "web" machine_type = "n1-standard-1" zone = "us-west1-a" disk { image = "ubuntu-os-cloud/ubuntu-1404-trusty-v20160602" } network_interface { network = "default" } }
  • 15. // variables.tf - inputs to the Terraform template variable "region" { description = "The region where the instance will be deployed." type = string default = "us-west1" } variable "region_zone" { description = "The zone where the instance will be deployed." type = string default = "us-west1-a" } variable "project_id" { description = "The ID of the GCP project." type = string }
  • 16. // outputs.tf - outputs (state) after the resource has been deployed // You can have a terraform.tfvars that contains all the input // values output "instance_id" { description = "The unique identifier of the deployed instance." type = string value = google_compute_instance.web.instance_id }
  • 17. Terraform Commands $ terraform init $ terraform plan $ terraform apply # Actual deployment to the Cloud $ terraform destroy You will see the following the following created: - .terraform - downloaded dependencies eg. modules, providers - *.tfstate - the current state of the infrastructure, basically a tree of the resources
  • 18. Demo
  • 19. Let’s run the Terraform code (might take a while) See Github repository: https://github.com/cybersamx/terraform-gke
  • 20. Connect to your GCP and Start Terraforming ● Launch your shell $ export PROJECT_ID='<YOUR_PROJECT_ID>' $ gcloud auth revoke # Log out $ gcloud init # Initialize with a project ID $ gcloud auth login $ # If the previous command doesn’t work try the following $ gcloud auth application-default login ● Now you are now connected to GCP, you can run terraform with the right access and authorization ● Go to the terraform project and the /dev folder and run the following $ terraform init $ terraform plan $ terraform apply
  • 21. GitOps ● Because Terraform is code, you can use existing workflows and tools for development and release ● Leverage existing workflow and tools with slight variation ● Collaborate as much as possible yet isolate as possible ● Break the Terraform configuration into multiple sets of files ● Versioning - Use git to store your Terraform code ● Isolate your environments through directories ○ Folder: dev, staging, prod ○ Branch: dev, staging, master ○ Environment: dev, staging, prod ● Start off with dev, build, test, and if it passes the current env promote to the next env ● Each environment folder has its own sets of configurations Reference: GitOps and Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
  • 22. Terraform Project Layout ● dev ○ network ○ services ■ frontend-app ■ backend-app ● variables.tf ● outputs.tf ● Main.tf ○ data-storage ● staging ● prod ● global ● modules Reference: Terraform: Up and Running, 2nd Ed. by Yevgeniy Brikman
  • 23. Let’s check the Terraform run and deploy containers to the new k8s cluster
  • 24. Deploying Containers to Cluster ● Now that we have set up a cluster and resources, let’s deploy an application ● We will be using a Hello World app example on Kubernetes home page ● First we need to set up kubectl for you to connect to the cluster $ gcloud container clusters get-credentials dev-cluster --region us-west1 $ kubectl config current-context $ gke_<PROJECT_ID>_us-west1_dev-cluster $ # You should see the above output $ # Query the cluster $ kubectl get node NAME READY UP-TO-DATE AVAILABLE AGE
  • 25. Troubleshooting Tips ● Start off a project interactively, get the gcloud equivalent, and then Terraform ● Set TF_LOG=TRACE ● Remove .terraform directory (back it up first) and rerun terraform init ● Run terraform console to play around with expressions