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

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 modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Anton Babenko
 
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
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformAdin Ermie
 
Microsoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformMicrosoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformAlex Mags
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformKnoldus Inc.
 
Terraform Introduction
Terraform IntroductionTerraform Introduction
Terraform Introductionsoniasnowfrog
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipelineAnton Babenko
 

What's hot (20)

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 modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018
 
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
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
Microsoft Azure IaaS and Terraform
Microsoft Azure IaaS and TerraformMicrosoft Azure IaaS and Terraform
Microsoft Azure IaaS and Terraform
 
Terraform Basics
Terraform BasicsTerraform Basics
Terraform Basics
 
Terraform 101
Terraform 101Terraform 101
Terraform 101
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Introduction to IAC and Terraform
Introduction to IAC and Terraform Introduction to IAC and Terraform
Introduction to IAC and Terraform
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Terraform
TerraformTerraform
Terraform
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Creating AWS infrastructure using Terraform
Creating AWS infrastructure using TerraformCreating AWS infrastructure using Terraform
Creating AWS infrastructure using Terraform
 
Advanced Terraform
Advanced TerraformAdvanced Terraform
Advanced Terraform
 
Terraform Introduction
Terraform IntroductionTerraform Introduction
Terraform Introduction
 
Terraform in deployment pipeline
Terraform in deployment pipelineTerraform in deployment pipeline
Terraform in deployment pipeline
 
Terraform
TerraformTerraform
Terraform
 

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
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209mffiedler
 

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
 
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
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209
 

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

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

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