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.
-
Clone this repository or open it in cloud shell, then go through the following steps to create resources:
-
Initialize the terraform configuration
terraform init
-
Apply the terraform configuration
terraform apply -var project_id=my-project-id
-
Copy the IP addresses for grafana, the locust master.
-
Change to the ansible directory and run the following command
ansible-playbook -v playbook.yaml
-
Open to the locust master web interface url in your browser and start the load test
-
SSH to the management VM
gcloud compute ssh mgmt --project my-project
-
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
-
Run the following command to see how the application pods scale
kubectl get hpa -n sample -w
-
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.
name | description | type | required | default |
---|---|---|---|---|
project_id | Project ID. | string |
✓ | |
cluster_network_config | Cluster network configuration. | object({…}) |
{…} |
|
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" |
name | description | sensitive |
---|---|---|
urls | Grafanam, locust and application URLs. |
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