Google Cloud | GCE Reliability Engineering using Terraform
All the code used for the demos for the Udemy Course
https://www.udemy.com/course/google-cloud-gce-reliability-engineering-using-terraform
Below are your options:
A. Linux/Mac User - If you ware comfortable with Linux, and have gcloud, terraform and packer installed on your machine, you are good, just follow the steps below. If you do not have the tools installed, and you are looking for an alternative easier path, follow option B.
B. Windows User - Use sreterminal jumpbox.
- Create a centos-7 VM with the startup_script_sreterminal
- gcloud compute ssh --zone $zone sreterminal --project $project_id'
ssh into the machine once the machine is up.
- gcloud --version; kubectl version; terraform --version; packer --version
Validate all the tools
- alias
Check the aliases BEFORE updating the bash profile
- cat /home/repos/utilities/aliases.md >> .bashrc
Update the bash profile with aliases
- source .bashrc
This is needed to make the changes take effect.
- sudo gsutil cp <gsutil_uri_to_your_credentials> /home/repos/gce_bootcamp/
The credentials file is needed for the terraform scripts to run.
sudo gsutil cp gs://codegarage-credentials/credentials.json /home/repos/gce_bootcamp/
Important to follow, else Test and Validate will fail
- Download the Compute Engine default service account key, and save it as credentials.json in the root folder. Refer sa_key_download.
- Navigate to packer folder and run the following commands
packer build -force statichtml.centos.packer.json
Build the statichtml webserver imagepacker build -force statichtmlwithjs.debian.packer.json
Build the statichtmlwithjs webserver imagepacker build -force grafana.debian.packer.json
Build the grafana image
- Terraform Config Modifications
global.tfvars
Modify to match your project details- Update
backend.tf
in all stages folders to change the bucket name to your gcs bucket - Update
variable.tf
in all stages folders to change the project name to your project
Navigate to each stage folder, and run the following commands with sudo permissions:
terraform init
validate for successful completion. Resolve errors.terraform plan --var-file ../global.tfvars
validate outputterraform apply
to create the resourcesterraform state list
should show the resources created per the planterraform destroy
to create the resources without sudo, you will run into issues likeUnable to write the module manifest file: open .terraform/modules/modules.json: permission denied
Packer build json configurations for both statichtml and statichtmlwithjs websites.
- startup and install scripts for debian, centos, grafana
- Terraform configuration for instance creation
- Backend is GCS
- Uses the terraform_modules from the sre repo.
- Introduced Terraform.
- Create instances using the Instance module (not the instance templates)
- Introduced Instance Templates
- Create instances from Instance template; MIGs not created yet
- Introduced MIGs
- Create MIGs that use the Instance templates
- Introduced Load Balancers
- Create HTTP Load Balancers that uses MIGs as backends
- Configured only for the web apps - statichtml and statichtmlwithjs
- Get rid of external ips
- Implement Cloud NAT
- Configure DNS (manually, not in the terraform scripts)
Demo Apps for various Stages
- static-html - Static HTML website with no JS.
- static-html-with-js - Static HTML website with JS.
Images referenced in the markdown files