Skip to content

Latest commit

 

History

History
 
 

Load testing an application running on an autopilot cluster

This blueprint creates an Autopilot cluster with Google-managed Prometheus enabled and installs an application that scales as the traffic that is hitting the load balancer exposing it grows. It also installs the tooling required to distributed load test with locust on that application and the monitoring tooling required to observe how things evolve in the cluster during the load test. Ansible is used to install the application and all the tooling on a management VM.

The diagram below depicts the architecture.

Diagram

Running the blueprint

  1. Clone this repository or open it in cloud shell, then go through the following steps to create resources:

  2. Initialize the terraform configuration

    terraform init
    
  3. Apply the terraform configuration

    terraform apply -var project_id=my-project-id
    
  4. Copy the IP addresses for grafana, the locust master.

  5. Change to the ansible directory and run the following command

    ansible-playbook -v playbook.yaml
    
  6. Open to the locust master web interface url in your browser and start the load test

  7. SSH to the management VM

    gcloud compute ssh mgmt --project my-project
    
  8. Run the following command to check that the application pods are running on different nodes than the load testing and monitoring tooling.

    kubectl get pods -A -o wide
    
  9. Run the following command to see how the application pods scale

    kubectl get hpa -n sample -w
    
  10. Run the following command to see how the cluster nodes scale

    kubectl get nodes -n
    

Alternatively you can also check all the above using the dashboards available in grafana.

Variables

name description type required default
project_id Project ID. string
cluster_network_config Cluster network configuration. object({…}) {…}
deletion_protection Prevent Terraform from destroying data storage resources (storage buckets, GKE clusters, CloudSQL instances) in this blueprint. When this field is set in Terraform state, a terraform destroy or terraform apply that would delete data storage resources will fail. bool false
mgmt_server_config Management server configuration. object({…}) {…}
mgmt_subnet_cidr_block Management subnet IP CIDR range. string "10.0.2.0/24"
project_create Parameters for the creation of the new project. object({…}) null
region Region. string "europe-west1"
vpc_create Flag indicating whether the VPC should be created or not. bool true
vpc_name VPC name. string "vpc"

Outputs

name description sensitive
urls Grafanam, locust and application URLs.

Test

module "test" {
  source = "./fabric/blueprints/gke/autopilot"
  project_create = {
    billing_account_id = "12345-12345-12345"
    parent             = "folders/123456789"
  }
  project_id = "my-project"
}
# tftest modules=11 resources=36