Skip to content

K6 operator on Kubernetes

Published: at 11:30 AM

The k6 operator can be installed on a Kubernetes cluster to enable load testing on the cluster and cloud in a distributed manner.

Writing and saving tests

Getting values from env vars

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: k6-test
spec:
  parallelism: 4
  script:
    configMap:
      name: test-k6-cm
      file: test.js
  runner:
    envFrom:
      - secretRef:
          name: example-secret

Prometheus and exporting to Grafana

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: k6-test
spec:
	arguments: -o experimental-prometheus-rw
  parallelism: 4
  script:
    configMap:
      name: test-k6-cm
      file: test.js
  runner:
		env:
			- name: K6_PROMETHEUS_RW_SERVER_URL
				value: http://localhost:9090/api/v1/write
			- name: K6_PROMETHEUS_RW_TREND_STATS
				value: p(95),p(99),min,max,avg,count,sum
    envFrom:
      - secretRef:
          name: example-secret