# st-tech/gatling-operator architecture

> Architecture diagram of the GitHub repository st-tech/gatling-operator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/st-tech/gatling-operator
- Repository: https://github.com/st-tech/gatling-operator

## Overview

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: [`controllers/gatling_controller.go`](https://github.com/st-tech/gatling-operator/blob/main/controllers/gatling_controller.go) (Gatling controller), [`pkg/cloudstorages/cloudstorage.go`](https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/cloudstorage.go) (Cloud storage), [`api/v1alpha1/gatling_types.go`](https://github.com/st-tech/gatling-operator/blob/main/api/v1alpha1/gatling_types.go) (Gatling API), [`docs/architecture.md`](https://github.com/st-tech/gatling-operator/blob/main/docs/architecture.md) (Docs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_control["Control plane"]
  node_node_main["main.go<br/>manager entrypoint<br/>[main.go]"]
  node_node_controller["Gatling controller<br/>reconciler"]
  node_node_api["Gatling API<br/>CRD types<br/>[gatling_types.go]"]
  node_node_commands["Command builder<br/>execution helper<br/>[commands.go]"]
  node_node_utils["Shared utils<br/>helpers<br/>[utils.go]"]
end

subgraph group_group_runtime["Test runtime"]
  node_node_gatling_assets["Gatling assets<br/>runtime assets"]
  node_node_gatling_conf["Gatling config<br/>runtime config<br/>[gatling.conf]"]
end

subgraph group_group_integrations["External services"]
  node_node_storage["Cloud storage<br/>report upload<br/>[cloudstorage.go]"]
  node_node_s3["S3 backend<br/>storage adapter<br/>[s3.go]"]
  node_node_gcp["GCS backend<br/>storage adapter<br/>[gcp.go]"]
  node_node_azure["Azure backend<br/>storage adapter<br/>[azure.go]"]
  node_node_notify["Notifications<br/>post-run alerts"]
  node_node_slack["Slack<br/>notification adapter<br/>[slack.go]"]
end

subgraph group_group_cluster["Cluster packaging"]
  node_node_crd["CRD manifests<br/>kubebuilder config"]
  node_node_manager_cfg["Manager config<br/>operator config<br/>[manager.yaml]"]
  node_node_rbac["RBAC<br/>cluster policy<br/>[role.yaml]"]
  node_node_metrics["Metrics<br/>prometheus monitor<br/>[monitor.yaml]"]
  node_node_samples["Samples<br/>example manifests"]
  node_node_kind["Kind cluster<br/>dev cluster<br/>[cluster.yaml]"]
  node_node_docs["Docs<br/>[architecture.md]"]
end

node_node_main -->|"starts"| node_node_controller
node_node_controller -->|"watches"| node_node_api
node_node_controller -->|"builds"| node_node_commands
node_node_controller -->|"uses"| node_node_utils
node_node_controller -->|"uploads reports"| node_node_storage
node_node_controller -->|"sends alerts"| node_node_notify
node_node_controller -.->|"requires"| node_node_rbac
node_node_controller -.->|"deployed by"| node_node_manager_cfg
node_node_api -->|"materialized as"| node_node_crd
node_node_api -.->|"shown in"| node_node_samples
node_node_controller -->|"mounts"| node_node_gatling_assets
node_node_controller -->|"configures"| node_node_gatling_conf
node_node_storage -->|"implements"| node_node_s3
node_node_storage -->|"implements"| node_node_gcp
node_node_storage -->|"implements"| node_node_azure
node_node_notify -->|"implements"| node_node_slack
node_node_rbac -.->|"authorizes"| node_node_controller
node_node_metrics -.->|"scrapes"| node_node_controller
node_node_kind -.->|"supports"| node_node_manager_cfg
node_node_docs -.->|"describes"| node_node_api
node_node_docs -.->|"describes"| node_node_controller

click node_node_main "https://github.com/st-tech/gatling-operator/blob/main/main.go"
click node_node_controller "https://github.com/st-tech/gatling-operator/blob/main/controllers/gatling_controller.go"
click node_node_api "https://github.com/st-tech/gatling-operator/blob/main/api/v1alpha1/gatling_types.go"
click node_node_crd "https://github.com/st-tech/gatling-operator/blob/main/config/crd/bases/gatling-operator.tech.zozo.com_gatlings.yaml"
click node_node_manager_cfg "https://github.com/st-tech/gatling-operator/blob/main/config/manager/manager.yaml"
click node_node_rbac "https://github.com/st-tech/gatling-operator/blob/main/config/rbac/role.yaml"
click node_node_metrics "https://github.com/st-tech/gatling-operator/blob/main/config/prometheus/monitor.yaml"
click node_node_samples "https://github.com/st-tech/gatling-operator/blob/main/config/samples/gatling-operator_v1alpha1_gatling01.yaml"
click node_node_gatling_assets "https://github.com/st-tech/gatling-operator/blob/main/gatling/user-files/simulations/MyBasicSimulation.scala"
click node_node_gatling_conf "https://github.com/st-tech/gatling-operator/blob/main/gatling/conf/gatling.conf"
click node_node_commands "https://github.com/st-tech/gatling-operator/blob/main/pkg/commands/commands.go"
click node_node_utils "https://github.com/st-tech/gatling-operator/blob/main/pkg/utils/utils.go"
click node_node_storage "https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/cloudstorage.go"
click node_node_s3 "https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/s3.go"
click node_node_gcp "https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/gcp.go"
click node_node_azure "https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/azure.go"
click node_node_notify "https://github.com/st-tech/gatling-operator/blob/main/pkg/notificationservices/notificationservice.go"
click node_node_slack "https://github.com/st-tech/gatling-operator/blob/main/pkg/notificationservices/slack.go"
click node_node_kind "https://github.com/st-tech/gatling-operator/blob/main/config/kind/cluster.yaml"
click node_node_docs "https://github.com/st-tech/gatling-operator/blob/main/docs/architecture.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_main,node_node_controller,node_node_api,node_node_commands,node_node_utils toneBlue
class node_node_gatling_assets,node_node_gatling_conf toneAmber
class node_node_storage,node_node_s3,node_node_gcp,node_node_azure,node_node_notify,node_node_slack toneMint
class node_node_crd,node_node_manager_cfg,node_node_rbac,node_node_metrics,node_node_samples,node_node_kind,node_node_docs toneRose
```

## Components

### Control plane

Kubernetes API surface and reconciliation logic for Gatling resources.

- [main.go](https://github.com/st-tech/gatling-operator/blob/main/main.go): manager entrypoint · Starts the controller manager and wires the operator process. · `main.go`
- [Gatling controller](https://github.com/st-tech/gatling-operator/blob/main/controllers/gatling_controller.go): reconciler · Core reconciliation loop that watches Gatling CRs and drives the test lifecycle. · `controllers/gatling_controller.go`
- [Gatling API](https://github.com/st-tech/gatling-operator/blob/main/api/v1alpha1/gatling_types.go): CRD types · Custom resource definition and Go types for Gatling workloads. · `api/v1alpha1/gatling_types.go`
- [Command builder](https://github.com/st-tech/gatling-operator/blob/main/pkg/commands/commands.go): execution helper · Assembles command lines used to launch Gatling and related runtime steps. · `pkg/commands/commands.go`
- [Shared utils](https://github.com/st-tech/gatling-operator/blob/main/pkg/utils/utils.go): helpers · 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](https://github.com/st-tech/gatling-operator/blob/main/gatling/user-files/simulations/MyBasicSimulation.scala): runtime assets · Bundled Gatling configuration, simulations, and sample resources mounted into test runs. · `gatling/user-files/simulations/MyBasicSimulation.scala`
- [Gatling config](https://github.com/st-tech/gatling-operator/blob/main/gatling/conf/gatling.conf): runtime config · Runtime configuration files for Gatling execution and logging. · `gatling/conf/gatling.conf`

### External services

Post-run storage and notification integrations.

- [Cloud storage](https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/cloudstorage.go): report upload · Abstracts report uploads to S3, GCS, and Azure Blob Storage via runtime tooling. · `pkg/cloudstorages/cloudstorage.go`
- [S3 backend](https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/s3.go): storage adapter · Amazon S3 implementation for report storage. · `pkg/cloudstorages/s3.go`
- [GCS backend](https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/gcp.go): storage adapter · Google Cloud Storage implementation for report storage. · `pkg/cloudstorages/gcp.go`
- [Azure backend](https://github.com/st-tech/gatling-operator/blob/main/pkg/cloudstorages/azure.go): storage adapter · Azure Blob Storage implementation for report storage. · `pkg/cloudstorages/azure.go`
- [Notifications](https://github.com/st-tech/gatling-operator/blob/main/pkg/notificationservices/notificationservice.go): post-run alerts · Abstraction for sending post-test notifications after execution completes. · `pkg/notificationservices/notificationservice.go`
- [Slack](https://github.com/st-tech/gatling-operator/blob/main/pkg/notificationservices/slack.go): notification adapter · 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](https://github.com/st-tech/gatling-operator/blob/main/config/crd/bases/gatling-operator.tech.zozo.com_gatlings.yaml): kubebuilder config · Generated CRD, webhook patches, and reference docs for the Gatling resource. · `config/crd/bases/gatling-operator.tech.zozo.com_gatlings.yaml`
- [Manager config](https://github.com/st-tech/gatling-operator/blob/main/config/manager/manager.yaml): operator config · Controller manager deployment and runtime configuration for the operator. · `config/manager/manager.yaml`
- [RBAC](https://github.com/st-tech/gatling-operator/blob/main/config/rbac/role.yaml): cluster policy · Service account, roles, bindings, and permissions required by the operator. · `config/rbac/role.yaml`
- [Metrics](https://github.com/st-tech/gatling-operator/blob/main/config/prometheus/monitor.yaml): prometheus monitor · Prometheus scrape configuration and monitoring integration for the operator. · `config/prometheus/monitor.yaml`
- [Samples](https://github.com/st-tech/gatling-operator/blob/main/config/samples/gatling-operator_v1alpha1_gatling01.yaml): example manifests · Example Gatling resources, secrets, and service-account manifests for users. · `config/samples/gatling-operator_v1alpha1_gatling01.yaml`
- [Kind cluster](https://github.com/st-tech/gatling-operator/blob/main/config/kind/cluster.yaml): dev cluster · Local Kubernetes cluster configuration for development and testing. · `config/kind/cluster.yaml`
- [Docs](https://github.com/st-tech/gatling-operator/blob/main/docs/architecture.md): project docs · Architecture, API, build, quickstart, and user guidance for the operator. · `docs/architecture.md`

## Connections

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