terraform/README.md
This page walks you through the steps required to deploy the Online Boutique sample application on a Google Kubernetes Engine (GKE) cluster using Terraform.
Clone the Github repository.
git clone https://github.com/GoogleCloudPlatform/microservices-demo.git
Move into the terraform/ directory which contains the Terraform installation scripts.
cd microservices-demo/terraform
Open the terraform.tfvars file and replace <project_id_here> with the GCP Project ID for the gcp_project_id variable.
(Optional) If you want to provision a Google Cloud Memorystore (Redis) instance, you can change the value of memorystore = false to memorystore = true in this terraform.tfvars file.
Initialize Terraform.
terraform init
See what resources will be created.
terraform plan
Create the resources and deploy the sample.
terraform apply
yes and hit Enter/Return.Note: This step can take about 10 minutes. Do not interrupt the process.
Once the Terraform script has finished, you can locate the frontend's external IP address to access the sample application.
Option 1:
kubectl get service frontend-external | awk '{print $4}'
Option 2: On Google Cloud Console, navigate to "Kubernetes Engine" and then "Services & Ingress" to locate the Endpoint associated with "frontend-external".
To avoid incurring charges to your Google Cloud account for the resources used in this sample application, either delete the project that contains the resources, or keep the project and delete the individual resources.
To remove the individual resources created for by Terraform without deleting the project:
Navigate to the terraform/ directory.
Set deletion_protection to false for the google_container_cluster resource (GKE cluster).
# Uncomment the line: "deletion_protection = false"
sed -i "s/# deletion_protection/deletion_protection/g" main.tf
# Re-apply the Terraform to update the state
terraform apply
Run the following command:
terraform destroy
yes and hit Enter/Return.