This page walks you through the steps required to deploy the Online Boutique sample application on a Google Kubernetes Engine (GKE) cluster using Terraform.
- Create a new project or use an existing project on Google Cloud, and ensure billing is enabled on the project.
-
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 thegcp_project_id
variable. -
(Optional) If you want to provision a Google Cloud Memorystore (Redis) instance, you can change the value of
memorystore = false
tomemorystore = true
in thisterraform.tfvars
file. -
Initialize Terraform.
terraform init
-
See what resources will be created.
terraform plan
-
Create the resources and deploy the sample.
terraform apply
- If there is a confirmation prompt, type
yes
and hit Enter/Return.
Note: This step can take about 10 minutes. Do not interrupt the process.
- If there is a confirmation prompt, type
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
tofalse
for thegoogle_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
- If there is a confirmation prompt, type
yes
and hit Enter/Return.
- If there is a confirmation prompt, type