Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Terraform code to automate Online Boutique GKE quickstart #918

Merged
merged 38 commits into from
Jul 26, 2022

Conversation

jaspermai
Copy link
Contributor

@jaspermai jaspermai commented Jul 15, 2022

This Pull Request introduces a new Terraform module that automates Online Boutique's GKE quickstart process.

Background

Online Boutique (microservices-demo) is a sample web application that simulates a web-based e-commerce application for users to browse items, add them to cart, and purchase them. The sample application demonstrates using an 11-tier microservices application deployed using Kubernetes/GKE.

Currently, the microservices-demo repo contains instructions in the Quickstart (GKE) section on how to deploy the sample application on your own GCP project. The process requires many intermediate steps with varying processing time in between each step. The usage of an incoming Terraform module will simplify all of the Quickstart steps into one Terraform command and combine the individual processing times into one waiting period for the user.

Summary of Changes

1. New File: main.tf
This file contains the main Terraform script instructions. When running the script, the script will be executing the following actions:

  1. Enable the required Google APIs outlined in "Quickstart (GKE)"
  2. Create an autopilot GKE cluster and point kubectl at the new cluster (get-credentials)
  3. Apply the kubernetes manifest file in release/kubernetes-manifests.yaml
  4. Wait on all the Pods to be ready

2. New File: variables.tf
This file contains variables that may need customization in future projects. These variables include "apis", "cluster name", "cluster region", "Pods namespace", and "Kubernetes manifest filepath".

3. New File: output.tf
This file contains output variables that are shown after running the Terraform script. These variables include "location of the cluster" and "name of the cluster".

4. New File: README.md
This file contains detailed instructions on how to setup, run, and destroy the Terraform script.

Testing Procedure

Refer to the instructions in the terraform/README.md file. This file contains instructions of setting up and using the Terraform file. Link to README: https://github.com/GoogleCloudPlatform/microservices-demo/blob/7d2517ef8f1e9cfbfd110e855bc801081988eb45/terraform/README.md

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

1 similar comment
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

1 similar comment
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

Copy link
Collaborator

@NimJay NimJay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that this pull-request is in "Draft" mode.
But I left some preliminary comments/suggestions.
Feel free to reject any of my suggestions — all of them are minor.

I have not yet tested the instructions myself (i.e., I didn't run the terraform commands).
I will do that as soon as this pull-requests come out of draft mode. :)

Things are looking good! Great work so far, Jasper. 👏

terraform/README.md Outdated Show resolved Hide resolved
terraform/README.md Outdated Show resolved Hide resolved
terraform/README.md Outdated Show resolved Hide resolved
terraform/main.tf Outdated Show resolved Hide resolved
terraform/main.tf Show resolved Hide resolved
terraform/variables.tf Outdated Show resolved Hide resolved
terraform/README.md Outdated Show resolved Hide resolved
terraform/README.md Outdated Show resolved Hide resolved
terraform/README.md Outdated Show resolved Hide resolved
@jaspermai jaspermai self-assigned this Jul 18, 2022
@ahrarmonsur ahrarmonsur self-requested a review July 18, 2022 14:09
jaspermai and others added 5 commits July 18, 2022 10:14
Co-authored-by: Nim Jayawardena <nimjay@google.com>
Co-authored-by: Nim Jayawardena <nimjay@google.com>
Co-authored-by: Nim Jayawardena <nimjay@google.com>
Co-authored-by: Nim Jayawardena <nimjay@google.com>
Co-authored-by: Nim Jayawardena <nimjay@google.com>
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

4 similar comments
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

Copy link
Member

@Shabirmean Shabirmean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all my comments!

Copy link
Collaborator

@NimJay NimJay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaspermai

Thank you so, so much for addressing most of our feedback!
Your changes have come a long way since you first drafted this pull-request (PR).
It was already excellent when you created the PR so your extra efforts (to address our comments) are highly appreciated.

I approve this change.

Before merging, please:

  1. Get Ahrar's approval.
  2. Merge the latest changes from main into this branch (click "Update branch").
  3. Wait for all 4 Checks to pass (it'll take a few minutes).

@ahrarmonsur
Copy link
Contributor

This is regarding @Shabirmean's suggestion to use terraform-docs to generate docs similar to this. Great suggestion. But I'll let @ahrarmonsur decide whether we should proceed. Ahrar, if you do decide to use terraform-docs, let's do it outside this pull-request. I want to make sure all our feedback & requests don't demotivate Jasper. :)

Both of you, good suggestion and supporting references. I agree, let's consider this improvement out-of-scope for this PR. Jasper and I will discuss his interest in implementing this and incorporating references to the docs into the README, after the fact.

@jaspermai
Copy link
Contributor Author

@minherz @ckim328 @ahrarmonsur (+ @NimJay & @Shabirmean if necessary) - requesting a final code look-through after many of your comments have been addressed! Here are the main changes to the Terraform module:

  • "gcloud get-credentials" command is now taken care of in the gcloud module (CC: @minherz , @ckim328 , @Shabirmean )
  • users are prompted to change the gcp_project_id variable in terraform.tfvars instead of variables.tf (CC: @ckim328 , @ahrarmonsur )
  • providers.tf and copyright messages have been added where necessary (CC: @minherz )
  • README.md and .tf file styling looks much better
  • .gitignore is properly populated (CC: @ckim328 )
  • Note: There is a unique workaround in main.tf that uses local variables to implicitly declare a dependency between module gcloud and resource google_container_cluster.

terraform/main.tf Outdated Show resolved Hide resolved
terraform/main.tf Outdated Show resolved Hide resolved
Copy link
Member

@Shabirmean Shabirmean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @jaspermai
Left two minor improvements.

LGTM!!!

@xtineskim xtineskim requested a review from a team July 25, 2022 15:57
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

.gitignore Show resolved Hide resolved
Copy link
Contributor

@xtineskim xtineskim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job Jasper, and thank you for addressing all our comments! just one last comment from myself

Copy link
Contributor

@ahrarmonsur ahrarmonsur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent job incorporating everyone's feedback, Jasper, including my own for the README!
Your diligence with you the contribution is evident, and the final state is much improved since you submitted the PR!

LGTM!

@jaspermai jaspermai requested a review from a team July 26, 2022 15:28
@github-actions
Copy link

🚲 PR staged at http://34.170.66.255

@jaspermai jaspermai merged commit 359be44 into main Jul 26, 2022
@jaspermai jaspermai deleted the terraform branch July 26, 2022 17:32
D-Mwanth pushed a commit to D-Mwanth/microservices-demo that referenced this pull request Mar 6, 2024
…tart (GoogleCloudPlatform#918)

* basic files upload - main, output, variables, README, LICENSE

* Delete LICENSE

* Update README.md

* Updated README.md

* Updated README.md

* Updated README.md

* Update terraform/README.md

Co-authored-by: Nim Jayawardena <nimjay@google.com>

* Update terraform/README.md

Co-authored-by: Nim Jayawardena <nimjay@google.com>

* Update terraform/main.tf

Co-authored-by: Nim Jayawardena <nimjay@google.com>

* Update terraform/variables.tf

Co-authored-by: Nim Jayawardena <nimjay@google.com>

* Update terraform/README.md

Co-authored-by: Nim Jayawardena <nimjay@google.com>

* Updated README.md

* Updated README.md

* updated .gitignore file with unneccessary tf-generated files

* updated README as per nimjay@

* updated README.md

* .gitignore and README.md changes as per christineskim@

* updated README.md

* Updated README.md

* Updated main.tf and variables.tf as per leoy@

* Updated README and .tf files as per christineskim@, leoy@, ahrar@, shabirmean@. Providers-related code in progress

* Ran terraform fmt and updated README

* Transitioned to terraform.tfvars and providers definition

* Using gcloud module for get-credentials

* Updated styling

* Updated styling

* Update terraform/main.tf

Co-authored-by: Shabir Mohamed Abdul Samadh <7249208+Shabirmean@users.noreply.github.com>

* Changed naming of cluster_id_parts

* Changed cluster_id_parts

* Updated README.md for formatting

* Reverted tfvars variable to project_id_here

* Updated .gitignore

Co-authored-by: Nim Jayawardena <nimjay@google.com>
Co-authored-by: Christine Kim <35876108+ckim328@users.noreply.github.com>
Co-authored-by: Shabir Mohamed Abdul Samadh <7249208+Shabirmean@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants