How st-tech/gatling-operator works
1. Repository purpose
- This is a Go-based Kubernetes Operator for running distributed Gatling load tests.
- The operator turns a custom resource, Gatling, into an automated test lifecycle: launch, run, report, notify, and clean up.
2. Control plane boundary
- The main architectural boundary is between Kubernetes control logic and load-test execution.
- Kubernetes holds the desired state in a Gatling CRD; the operator watches those resources and reconciles them into runtime objects such as pods, service accounts, secrets, and related config.
3. Custom API surface
- The API is defined under api/v1alpha1.
- The generated CRD and supporting manifests live in config/crd, which makes Gatling a first-class Kubernetes resource with RBAC and admission/webhook-related patches.
4. Reconciliation loop
- main.go starts the controller manager.
- controllers/gatling_controller.go is the core reconciliation loop that reacts to Gatling resource changes and drives the test lifecycle.
- This controller is the central orchestration point for starting tests, observing completion, and triggering post-run actions.
5. Runtime execution model
- The operator is designed to run Gatling workloads inside Kubernetes pods, including horizontal scaling across multiple pods.
- The repo’s gatling/ directory contains Gatling runtime assets, configuration, and sample simulations, which suggests the operator supports packaging or mounting test code/resources into the execution environment.
- The README also indicates support for multiple input styles: bundled runtime image, build-tool-generated artifacts, or inline definitions in the CR.
6. Reporting pipeline
- After a run, the operator can generate aggregated HTML reports.
- Reports are uploaded to external object storage through the pkg/cloudstorages abstraction, with concrete support for Amazon S3, Google Cloud Storage, and Azure Blob Storage.
- The storage upload path is explicitly integrated with rclone in the runtime model.
7. Notification pipeline
- The pkg/notificationservices package abstracts post-test notifications.
- The visible concrete integration is Slack, which is configured through Kubernetes Secrets and used to send test results or webhook messages after execution.
8. Command construction and execution helpers
- pkg/commands appears to centralize the command-line assembly used to drive Gatling execution and related runtime steps.
- pkg/utils contains shared helper logic used across controller and service packages.
9. Cluster deployment and policy
- config/manager, config/default, config/rbac, and config/prometheus define how the operator is deployed in-cluster.
- RBAC is separated from the controller logic, which is important because the operator needs permissions to manage workload resources and read/write secrets/config.
- Prometheus integration indicates the operator exposes operational metrics.
10. Operational dependencies
- The operator expects Kubernetes cluster access and uses standard operator packaging: Dockerfiles, kustomize manifests, and CI/CD workflows.
- config/kind and the devcontainer/Docker setup suggest local development and cluster-based testing are first-class workflows.
11. Example and user-facing assets
- config/samples contains example Gatling resources, service-account examples, and notification/storage secrets.
- docs/ provides architecture, API, quickstart, and build guidance, so the repo is structured as both an operator implementation and its deployment/documentation package.
12. How to draw the architecture
- At the center, place the Kubernetes API server with the Gatling CRD.
- Next, place the Gatling controller manager watching CRs and creating/managing runtime pods.
- Around it, show Gatling runtime pods consuming simulations/resources and emitting results.
- Add external arrows from those pods to cloud storage for reports and Slack/notification endpoints for result delivery.
- Finally, show the supporting cluster layer: RBAC, metrics, config, and sample manifests that enable the operator to run safely in a cluster.
Main entry points: gatling_controller.go Gatling controller · cloudstorage.go Cloud storage · gatling_types.go Gatling API · architecture.md Docs
Components 20
Control plane
Kubernetes API surface and reconciliation logic for Gatling resources.
- main.go · Starts the controller manager and wires the operator process.
main.go - Gatling controller · Core reconciliation loop that watches Gatling CRs and drives the test lifecycle.
controllers/gatling_controller.go - Gatling API · Custom resource definition and Go types for Gatling workloads.
api/v1alpha1/gatling_types.go - Command builder · Assembles command lines used to launch Gatling and related runtime steps.
pkg/commands/commands.go - Shared utils · Common helper functions used across the controller and service packages.
pkg/utils/utils.go
Test runtime
Assets and execution environment used to run distributed Gatling tests.
- Gatling assets · Bundled Gatling configuration, simulations, and sample resources mounted into test runs.
gatling/user-files/simulations/MyBasicSimulation.scala - Gatling config · Runtime configuration files for Gatling execution and logging.
gatling/conf/gatling.conf
External services
Post-run storage and notification integrations.
- Cloud storage · Abstracts report uploads to S3, GCS, and Azure Blob Storage via runtime tooling.
pkg/cloudstorages/cloudstorage.go - S3 backend · Amazon S3 implementation for report storage.
pkg/cloudstorages/s3.go - GCS backend · Google Cloud Storage implementation for report storage.
pkg/cloudstorages/gcp.go - Azure backend · Azure Blob Storage implementation for report storage.
pkg/cloudstorages/azure.go - Notifications · Abstraction for sending post-test notifications after execution completes.
pkg/notificationservices/notificationservice.go - Slack · Slack integration used to send test results or webhook messages.
pkg/notificationservices/slack.go
Cluster packaging
Deployment, RBAC, metrics, and sample manifests for running the operator in-cluster.
- CRD manifests · Generated CRD, webhook patches, and reference docs for the Gatling resource.
config/crd/bases/gatling-operator.tech.zozo.com_gatlings.yaml - Manager config · Controller manager deployment and runtime configuration for the operator.
config/manager/manager.yaml - RBAC · Service account, roles, bindings, and permissions required by the operator.
config/rbac/role.yaml - Metrics · Prometheus scrape configuration and monitoring integration for the operator.
config/prometheus/monitor.yaml - Samples · Example Gatling resources, secrets, and service-account manifests for users.
config/samples/gatling-operator_v1alpha1_gatling01.yaml - Kind cluster · Local Kubernetes cluster configuration for development and testing.
config/kind/cluster.yaml - Docs · Architecture, API, build, quickstart, and user guidance for the operator.
docs/architecture.md
Connections 21
- main.go → Gatling controller: starts · The entrypoint initializes the controller manager and registers the reconciler.
- Gatling controller → Gatling API: watches · The controller reacts to Gatling custom resources.
- Gatling controller → Command builder: builds · Reconciliation assembles execution commands for Gatling workloads.
- Gatling controller → Shared utils: uses · Shared helpers support reconciliation and resource handling.
- Gatling controller → Cloud storage: uploads reports · Post-run results are sent through the cloud storage abstraction.
- Gatling controller → Notifications: sends alerts · Completion and result notifications are dispatched after runs.
- Gatling controller → RBAC: requires · The reconciler depends on cluster permissions to manage runtime resources.
- Gatling controller → Manager config: deployed by · The controller runs under the operator manager configuration.
- Gatling API → CRD manifests: materialized as · The Go API is packaged into a CRD and related manifests.
- Gatling API → Samples: shown in · Sample resources demonstrate the custom API in use.
- Gatling controller → Gatling assets: mounts · Simulation code and resources are packaged into runtime pods.
- Gatling controller → Gatling config: configures · Runtime configuration is injected for Gatling execution.
- Cloud storage → S3 backend: implements · S3 is one concrete storage backend.
- Cloud storage → GCS backend: implements · GCS is one concrete storage backend.
- Cloud storage → Azure backend: implements · Azure Blob Storage is one concrete storage backend.
- Notifications → Slack: implements · Slack is the concrete notification integration.
- RBAC → Gatling controller: authorizes · RBAC grants the controller access to cluster resources and secrets.
- Metrics → Gatling controller: scrapes · Prometheus monitors operator metrics exposed by the manager.
- Kind cluster → Manager config: supports · Kind config is used for local cluster-based development.
- Docs → Gatling API: describes · Documentation explains the custom resource and usage.
- Docs → Gatling controller: describes · Documentation covers the operator workflow and architecture.