Terraform Lessons

*

https://github.com/hongleizhang/RSPapers

https://www.youtube.com/watch?v=SK74ECns%5Fo4

https://cloud.google.com/docs/terraform/maturity

Example of using Terraform with github

terraform {
    required_providers {
	github = {
	    source = "integrtations/github"
	    version = "~> 5.0"

	}
    }
}

# Configure  the Github provider
#provider "github" {
#    token = "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"
#}

# More secure way to provide the token in env variable
provider = "github" {}
  • Terraform cloud provides:

    • state storage
    • remote execution (execution from cloud)
    • includes secret storage
  • Terraform is an online service. Terraform stores the configuration as

series of files and these files create modules.

  • State is a DB usually stored as file locally or can be part of remote backend which is S3 or Terraform cloud or GCS.

  • State file is the view of the world for Terraform. It does not check what exists in cloud provider, but looks at the state file.

  • Terraform compares what the user wants (config file) against what exists in the state file and reconcile the diff.

## Installation

  • Install terraform executable
  • Install docker image by docker run hashicorp/terraform:latest

Commands: There are around 12 to 15 commands.

Step 1: init:

  • downloads terraform providers or make sure they exist.
  • It also ensures module availability
  • provider is interface for individual cloud services.

Step 2: plan:

  • Compares config file settings against state.
  • The output is the detailed plan of what terraform is going to do.
  • A plan file is created and used in step 3 “apply”.

Step 3: apply:

  • applies the suggested plan using the plan file.
  • fmt

    • terraform formats the config file to standarized format.
  • graph

    • visualizes the dependency tree.
  • import

    • allows to bring the resources that were created outside terraform
  • output

    • display on the screen any output configured in terraform.
  • refresh

    • Update local state file against real resources and useful if there is any drfit.
  • show

    • info. about state and plan file
  • workspace

    • alternative state of the state file…common use is dev, stage, production workspaces.

kubernetes Commands Reference

To health check kubernetes cluster

kubectl cluster-info

To view all the nodes in kubernetes cluster

kubectl get nodes

To view all pods in the kubernetes cluster

kubectl get pods –all-namespaces

To view all local containers

crictl ps

To ssh to second node

ssh node01

Dataiku Concepts

Previous
Next