Skip to content

Latest commit

 

History

History
 
 

terraform

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Use Terraform to deploy Online Boutique on a GKE cluster

This page walks you through the steps required to deploy the Online Boutique sample application on a Google Kubernetes Engine (GKE) cluster using Terraform.

Prerequisites

  1. Create a new project or use an existing project on Google Cloud Platform (GCP), and ensure billing is enabled on the project.

Deploy the sample application

  1. Clone the Github repository.

    git clone https://github.com/GoogleCloudPlatform/microservices-demo.git
    
  2. Move into the terraform/ directory which contains the Terraform installation scripts.

    cd microservices-demo/terraform
    
  3. Open the terraform.tfvars file and replace <project_id_here> with the GCP Project ID for the gcp_project_id variable.

  4. (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.

  5. Initialize Terraform.

    terraform init
    
  6. See what resources will be created.

    terraform plan
    
  7. Create the resources and deploy the sample.

    terraform apply
    
    1. 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.

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".

Clean up

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:

  1. Navigate to the terraform/ directory.

  2. Run the following command:

    terraform destroy
    
    1. If there is a confirmation prompt, type yes and hit Enter/Return.