GCP Classroom notes 23/Oct/2024

Google Anthos

  • This is officially deprecated as of now, Refer Here
  • Rightnow it is superseded by Google Kubernetes Enterprise Edition and Cloud Service Mesh

Infrastructure as Code (IaC)

  • With IaC you can define, deploy and manage your infrastructure in a repeatable and scalable way
  • In the world of GCP, We have two tools which are majorly of importance
    • Google cloud Deployment Manager: This is a native GCP IaC tool, this uses YAML, Jinja2 or Python to define and manage resources on GCP, Key Features are
      • Supports all Google cloud resources
      • Uses declarative configuration language (YAML)
      • Tight Integration with GCP Services
    • Terraform: This is one of the most popular IaC tools that work across multiple clouds including GCP & it uses a declarative language called as HCL to define infrastructure

Terraform Components (First Look)

  • Provider: This is where we want to create resources, we have AWS, Azure, GCP, Oracle Cloud, Vmware provider Refer Here. Generally we need to configure the authentication to Terraform provider to communicate with cloud provider
  • Resource: This is the resource of instructural element which we want to create
  • Arguments: This represents inputs which we provide to any terraform component
  • Attributes: This represents outputs which we get from any terraform component

Terraform Ways of Working

  • In terraform we create templates which are stored in a folder with .tf extension
  • The first step includes listing out resources which you want to create (list out manual steps)
  • Set up provider in a .tf file
  • Execute the command terraform init which downloads the provider in .terraform folder and also creates .terraform.lock.hcl which will have checksum of the providers downloaded.
  • Now add resources necessary and execute terraform validate to validate the template, terraform fmt to lint or format the terraform templates according to the best practice
  • Now apply to create the infrastructure

Installing Terraform

  • Refer Here for installation
  • Note: Ensure in vscode Terraform Extension from hashicorp is installed

HCL


Hello-terraform

  • To authenticate terraform to your gcp account Refer Here

Setup GCP Credentials

  1. Authenticate to google cloud using the gcloud CLI
gcloud auth application-default login
  1. Create a Service Account: Navigate to IAM & Admin -> Service Accounts. Create a new service account and download the key as JSON file.
  2. Set the environmental variable GOOGLE_APPLICATION_CREDENTIALS to the PATH of json file
# linux or mac
export GOOGLE_APPLICATION_CREDENTIALS=[Path to json]
# for permenant access use ~/.bash
# windows ps
$env:GOOGLE_APPLICATION_CREDENTIALS=[Path to json]
# set user or system environmental variables

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%