How do you execute distributed load tests in cloud-native Kubernetes environments using the k6 Operator?
Asked by The SDET Playbook
Asked Sep 28, 2026Viewed 0 times
How do you execute distributed load tests in cloud-native Kubernetes environments using the k6 Operator?
Asked by The SDET Playbook
Sign in to answer and to vote.
Install the k6 Operator in the cluster, put your script in a ConfigMap, and apply a TestRun resource. (Older guides use the kind K6, which TestRun replaced.)
kubectl create configmap k6-test --from-file=test.js
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: checkout-load
spec:
parallelism: 4
script:
configMap:
name: k6-test
file: test.js
arguments: --out experimental-prometheus-rw
runner:
resources:
requests:
cpu: "1"
memory: 2Gi
The operator starts an initializer job that checks the script, then parallelism runner pods that each run a slice of the load (k6 splits VUs and iterations between them with execution segments), and a starter job that starts all runners together. Results are sent to whatever output you pass in arguments, here Prometheus remote write for Grafana dashboards. Thresholds are evaluated per runner, not across the whole test, so aggregate metrics centrally when you gate on them.
Run the load generators in a different cluster or node pool from the system under test, so they don't compete for the same CPU, and set cleanup: 'post' in the spec, or delete the TestRun yourself, to remove its jobs and pods when the test ends.
Sources: k6: running distributed tests, k6 Operator: TestRun, k6: running large tests