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

Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsJulian Mazzitelli
 
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
 
Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersPlatform9
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Everything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesEverything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesThe {code} Team
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform TrainingYevgeniy Brikman
 
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
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewBob Killen
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Intro to Helm for Kubernetes
Intro to Helm for KubernetesIntro to Helm for Kubernetes
Intro to Helm for KubernetesCarlos E. Salazar
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetesrajdeep
 
Deep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingDeep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingSreenivas Makam
 

What's hot (20)

Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
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
TerraformTerraform
Terraform
 
Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It Matters
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Everything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in KubernetesEverything You Need To Know About Persistent Storage in Kubernetes
Everything You Need To Know About Persistent Storage in Kubernetes
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
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
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive Overview
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Intro to Helm for Kubernetes
Intro to Helm for KubernetesIntro to Helm for Kubernetes
Intro to Helm for Kubernetes
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Deep dive into Kubernetes Networking
Deep dive into Kubernetes NetworkingDeep dive into Kubernetes Networking
Deep dive into Kubernetes Networking
 
Introduction to IAC and Terraform
Introduction to IAC and Terraform Introduction to IAC and Terraform
Introduction to IAC and Terraform
 
Terraform
TerraformTerraform
Terraform
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 

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

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Recently uploaded (20)

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

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