This project is a cloud-native application deployed on Google Cloud Platform using Terraform. The application source code is taken from this repo. The cloud deployment architecture and infrastructure automation (Terraform, Kubernetes, Cloud Functions, Load Testing) are developed for the CmpE 48A Cloud Computing course by:
- Kerem Haktan Kurt
- Mustafa Batuhan Büber
heatHBack: Spring Boot Backend Application.heatHFront: React Frontend Application.terraform: Infrastructure as Code (IaC) configuration to provision GCP resources.k8s: Kubernetes manifests.functions: Google Cloud Functions (Java).locust: Load testing scripts using Locust.
Ensure you have the following tools installed on your local machine:
- Google Cloud SDK (
gcloud) - Terraform (v1.5.0+)
- kubectl (optional, for cluster management)
First, authenticate with Google Cloud to allow Terraform to create resources.
-
Login to your Google Cloud account:
gcloud auth login
-
Set your project ID:
gcloud config set project <your-gcp-project-id>
-
Check your project ID:
gcloud config get-value project
-
Grant Cloud Build permissions:
gcloud projects add-iam-policy-binding <your-gcp-project-id> --member="user:<your-email>" --role="roles/cloudbuild.builds.editor"
-
Configure Application Default Credentials (ADC) for Terraform:
gcloud auth application-default set-quota-project <your-gcp-project-id>
-
Navigate to the
terraformdirectory:cd terraform -
Open
terraform.tfvarsand update the values for your environment.- Important: You must update the
project_idto match your GCP Project ID. - Update
sendgrid_api_keyandsender_emailif you want email functionality to work.
Example
terraform.tfvars:project_id = "your-gcp-project-id"
- Important: You must update the
-
Initialize Terraform:
terraform init
-
Plan the deployment to see what will be created:
terraform plan
-
Apply the configuration to create the infrastructure:
terraform apply
- Type
yeswhen prompted to confirm. - Note: This process automatically builds the Docker images for the Frontend and Backend using Google Cloud Build and pushes them to the Artifact Registry. The initial deployment can take 15-20 minutes.
- Type
Once terraform apply completes successfully, you will see several outputs in your terminal:
frontend_external_ip: The public IP address to access the web application. Open this in your browser.vm_public_ip: The public IP of the PostgreSQL Database VM.get_credentials_command: A command to configurekubectlto connect to your new GKE cluster.
To view these outputs again later, run:
terraform output-
Kubernetes: Use the
get_credentials_commandoutput to configurekubectl, then use standard commands likekubectl get podsto check the status of your deployments. -
Load Testing with Locust: The
locustdirectory contains scripts for load testing the application's auto-scaling capabilities.-
Install Locust:
pip install locust
-
Configure Test Parameters:
- Load Config: You can modify
USERSandSPAWN_RATEdirectly inlocust/run_hpa.pyto simulate different traffic patterns. - Infrastructure Config: You can tune scaling behavior (like
gke_max_node_count,backend_hpa_max_replicas) interraform/terraform.tfvarsand apply changes withterraform apply.
- Load Config: You can modify
-
Run the Test:
python locust/run_hpa.py
This will start the load test and generate HTML reports in the
locust/results_hpadirectory, visualizing HPA scaling, Pod CPU usage, and Database Connection Pool status.
-
To destroy all resources and avoid incurring further costs:
cd terraform
terraform destroy