K6 Component

Load testing framework from Grafana. Auto-generates test scripts for linked infrastructure with custom scenarios and Prometheus metrics output.

Architecture

K6 Operator - Distributed test execution
Test Scripts - Auto-generated from links
TestRun CRD - K8s-native test orchestration
Prometheus - Metrics export
Grafana - Real-time dashboards

Quick Reference

Attribute Example Default Effect
namespace REQ k6 - Kubernetes namespace
vus 10 10 Virtual users count
duration 30s 30s Test duration
parallelism 4 1 Distributed runner pods

Sub-Components

endpoints SUB

Defines HTTP endpoints for API load testing. Creates endpoints.json and generic-test.js.

Attribute Example Description
url http://api.svc:8080 Base URL for the endpoint
path /api/users API path to test
method GET HTTP method (GET/POST/PUT/DELETE)
body {"name":"test"} Request body for POST/PUT
headers Content-Type: application/json Custom HTTP headers
auth bearer Auth type (bearer/basic)
Generates: k8s/deploy/base/k6/secret/endpoints.json
Test file: k8s/deploy/base/k6/tests/generic-test.js
TestRun: endpoint-test in test-run.yaml

custom_api SUB

User-defined custom API test configurations with advanced scenarios.

Attribute Example Description
name payment-api Custom API test name
script custom-payment.js Custom test script file
vus 50 Override default VUs
duration 5m Override default duration

Link to Sub-Components (Test Generation)

K6 can link to sub-components of other infrastructure to auto-generate specialized test scripts.

Link Type Target Sub-Component Variable Test Generated
k6-exchange rabbitmq → exchange __exchange RabbitMQ publish tests (rabbitmq.js)
k6-queue rabbitmq → queue __queue RabbitMQ consume tests
k6-database postgresql → database __reldb PostgreSQL query tests (psql.js)
k6-db cnpg → db __cnpg CloudNativePG tests (cnpg.js)
k6-mongo_db mongodb → mongo_db __mongodb MongoDB operation tests (mongo.js)
k6-topic kafka → topic __topic Kafka produce/consume tests (kafka.js)
k6-bucket minio → bucket __bucket S3 PUT/GET tests
gateway-k6 apisix → gateway __gateway Gateway route tests

Component Link Variables

Variable Link Type Effect
__prometheus prometheus-k6 Enables Prometheus metrics output
__ingress gateway-backend Gateway for test endpoints
__apisix apisix-k6 APISIX route exposure
__istio istio-k6 Service mesh integration
__postgresql k6-postgresql PostgreSQL connection
__rabbitmq k6-rabbitmq RabbitMQ connection
__celery k6-celery Celery task tests

Auto-Generated Test Types & Metrics

Test File Trigger Metrics
generic-test.js endpoints sub-component http_req_duration, http_req_failed, http_reqs
mongo.js k6-mongo_db link mongo_writes, mongo_reads, mongo_write_ms
kafka.js k6-topic link kafka_produces, kafka_consumes, kafka_produce_ms
rabbitmq.js k6-exchange/queue link rabbitmq_publishes, rabbitmq_publish_ms
cnpg.js k6-db link pg_query_time, pg_connections
psql.js k6-database link pg_query_time, pg_connections

Generated Files

File Condition Contains
tests/*.js Per linked target K6 test scripts
test-run.yaml Always TestRun CRDs per test type
secret/cloud.env Always Connection credentials
secret/endpoints.json endpoints sub-component HTTP endpoint configs

Prometheus Metrics Output

When __prometheus is linked:
- k6_http_req_duration (histogram)
- k6_http_req_failed (counter)
- k6_http_reqs (counter)
- k6_vus (gauge)
- k6_iterations (counter)

Output config: K6_PROMETHEUS_RW_SERVER_URL

Technical Info

Kaniko Version: v1.21.0 (for custom builds)
CRDs: TestRun (k6.io/v1alpha1)
Extensions: xk6-sql, xk6-kafka, xk6-amqp, xk6-mongo
Ports: 6565 (gRPC), 5656 (REST API)