Basic kube-burner Example
kube-burner is a Cloud Native Computing Foundation (CNCF) tool that stresses a Kubernetes cluster by creating, deleting and patching objects at scale, and measures how the cluster responds. Running it from Testkube lets you track control plane and kubelet performance over time, run it on a schedule or after a cluster upgrade, and fail an execution when latencies cross a threshold.
The example below runs a small pod density test: it creates a number of namespaces, each with one pod, measures how long the scheduler and kubelet take to start the pods, and deletes everything afterwards.
Prerequisites
kube-burner talks to the Kubernetes API of the cluster it runs in, so the execution pod needs a ServiceAccount allowed to create and delete the objects of the test. The default ServiceAccount that Testkube uses for executions does not have these permissions.
Apply the following to the cluster where your Testkube Runner Agent runs, in the namespace where it runs executions (testkube in this example):
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-burner
namespace: testkube
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kube-burner
rules:
# kube-burner creates a namespace per iteration and deletes them when done
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
# The objects the workload creates, and the podLatency measurement watches
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch", "create", "delete"]
# The podLatency measurement watches pod events
- apiGroups: [""]
resources: ["events"]
verbs: ["get", "list", "watch"]
# kube-burner reads node information for its cluster metadata
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kube-burner
subjects:
- kind: ServiceAccount
name: kube-burner
namespace: testkube
roleRef:
kind: ClusterRole
name: kube-burner
apiGroup: rbac.authorization.k8s.io
kubectl apply -f kube-burner-rbac.yaml
The ClusterRole only covers what this example creates: namespaces and pods, the events the podLatency measurement watches, and read access to nodes. If you change the workload to create other objects, such as Deployments or Services, add them to the ClusterRole.
kube-burner generates real load on the cluster it runs against. Start with a small number of iterations and run it against a test or staging cluster before you point it at a shared one.
The Workflow
Below is the Workflow. You can paste it into the YAML of a new or existing Workflow, after updating metadata.namespace to the namespace of your Testkube Agent.
apiVersion: testworkflows.testkube.io/v1
kind: TestWorkflow
metadata:
name: kube-burner-pod-density
namespace: testkube
labels:
docs: example
spec:
config:
iterations:
type: integer
default: 10
description: Number of job iterations; each iteration creates one namespace with one pod
qps:
type: integer
default: 5
description: Maximum number of API requests per second kube-burner sends
readyThreshold:
type: string
default: 30s
description: Maximum P99 latency for a pod to become Ready before the test fails
pod:
serviceAccountName: kube-burner
content:
files:
- path: /data/config.yml
content: |
global:
gc: true
measurements:
- name: podLatency
thresholds:
- conditionType: Ready
metric: P99
threshold: {{ config.readyThreshold }}
metricsEndpoints:
- indexer:
type: local
metricsDirectory: /data/metrics
jobs:
- name: pod-density
jobType: create
jobIterations: {{ config.iterations }}
qps: {{ config.qps }}
burst: {{ config.qps }}
namespace: kube-burner-pod-density
namespacedIterations: true
preLoadImages: false
podWait: false
waitWhenFinished: true
maxWaitTimeout: 5m
objects:
- objectTemplate: /data/pod.yml
replicas: 1
inputVars:
containerImage: registry.k8s.io/pause:3.10
- path: /data/pod.yml
content: |
apiVersion: v1
kind: Pod
metadata:
name: pod-density-{{ "{{.Iteration}}" }}-{{ "{{.Replica}}" }}
spec:
containers:
- name: pause
image: {{ "{{.containerImage}}" }}
resources:
requests:
cpu: 1m
memory: 8Mi
limits:
memory: 16Mi
- path: /data/kube-burner-to-lp.py
content: |
import glob
import json
import os
import sys
metrics_dir, output = sys.argv[1], sys.argv[2]
def tag(value):
# Escape the characters that line protocol treats as separators in tag values
return str(value).replace(",", r"\,").replace("=", r"\=").replace(" ", r"\ ")
lines = []
# One record per pod condition, with its latency quantiles in milliseconds
for path in glob.glob(os.path.join(metrics_dir, "podLatencyQuantilesMeasurement-*.json")):
for doc in json.load(open(path)):
fields = ",".join(
f"{key.lower()}={float(doc[key])}"
for key in ("P50", "P95", "P99", "max", "avg")
if key in doc
)
lines.append(
f"kube_burner_pod_latency_ms,job={tag(doc['jobName'])},"
f"condition={tag(doc['quantileName'])} {fields}"
)
# One record per job, with its duration and settings
summary = os.path.join(metrics_dir, "jobSummary.json")
if os.path.exists(summary):
for doc in json.load(open(summary)):
config = doc.get("jobConfig", {})
lines.append(
f"kube_burner_job,job={tag(config.get('name', 'unknown'))} "
f"elapsed_seconds={float(doc.get('elapsedTime', 0))},"
f"iterations={int(config.get('jobIterations', 0))}i,"
f"qps={int(config.get('qps', 0))}i,"
f"nodes={int(doc.get('totalNodes', 0))}i,"
f"passed={1 if doc.get('passed') else 0}i"
)
with open(output, "w") as f:
f.write("\n".join(lines) + "\n")
print(f"Wrote {len(lines)} records to {output}")
print("\n".join(lines))
steps:
- name: Run kube-burner
workingDir: /data
container:
image: quay.io/kube-burner/kube-burner:v2.8.6
run:
args:
- init
- --config=/data/config.yml
- --uuid={{ execution.id }}
- --timeout=15m
- name: Convert metrics to line protocol
condition: always
workingDir: /data
container:
image: python:3.13-alpine
run:
args:
- python
- /data/kube-burner-to-lp.py
- /data/metrics
- /data/metrics/kube-burner.lp
artifacts:
paths:
- metrics/**
spec.configdefines three parameters you can set when you run the Workflow: the number of iterations, the queries per second that kube-burner sends to the API server, and the P99 pod ready latency threshold.spec.pod.serviceAccountNameruns the execution pod with thekube-burnerServiceAccount from the prerequisites.spec.content.fileswrites three files into the execution pod:/data/config.ymlis the kube-burner configuration. It enables thepodLatencymeasurement with a threshold on the P99Readylatency, writes the collected metrics to/data/metricswith thelocalindexer, and defines onepod-densityjob that creates a namespace per iteration.gc: truedeletes the namespaces when the test ends, andpreLoadImages: falseskips the DaemonSet kube-burner otherwise creates to pull images in advance./data/pod.ymlis the object template that kube-burner creates in each iteration./data/kube-burner-to-lp.pyconverts the kube-burner metrics to custom metrics for Insights, as described in Custom metrics in Insights.
- The
Run kube-burnerstep uses the officialquay.io/kube-burner/kube-burnerimage, whose entrypoint is thekube-burnerbinary, and passes it theinitcommand. It passes the execution ID as the kube-burner run ID (--uuid), which ties the collected metrics to the execution. - The
Convert metrics to line protocolstep runs the conversion script in apythonimage.condition: alwaysruns it even when kube-burner fails on a latency threshold, so that a failed execution still records its metrics. artifactsuploads the JSON files that kube-burner writes to/data/metrics, and thekube-burner.lpfile that the conversion script writes next to them.
Go templates in content files
kube-burner object templates are Go templates, such as {{.Iteration}}, and Testkube evaluates expressions inside double curly brackets in content files. To pass a Go template through to kube-burner unchanged, wrap it in a Testkube string expression:
name: pod-density-{{ "{{.Iteration}}" }}-{{ "{{.Replica}}" }}
Testkube renders this as pod-density-{{.Iteration}}-{{.Replica}}, which kube-burner then fills in. Expressions without the quotes, such as {{ config.iterations }} in the configuration file, work as usual.
Running the Workflow
Create and run the Workflow with the Testkube CLI:
testkube create testworkflow -f kube-burner-workflow.yaml
testkube run testworkflow kube-burner-pod-density -f
Override the parameters with --config, for example to create more pods:
testkube run testworkflow kube-burner-pod-density --config iterations=50 --config qps=10 -f
The log output shows the iterations, the latency quantiles of each pod condition and the garbage collection of the created namespaces:
level=info msg="Triggering job: pod-density"
level=info msg="Waiting up to 5m0s for actions to be completed"
level=info msg="Job pod-density took 6s"
level=info msg="Evaluating latency thresholds"
level=info msg="pod-density: PodScheduled 99th: 875 ms max: 976 ms avg: 529 ms"
level=info msg="pod-density: Ready 99th: 4500 ms max: 5000 ms avg: 3000 ms"
level=info msg="File /data/metrics/podLatencyQuantilesMeasurement-pod-density.json now contains 6 documents"
level=info msg="Deleting 10 namespaces with label: kube-burner.io/job=pod-density"
When the P99 Ready latency is higher than readyThreshold, kube-burner logs an error and exits with code 1, so the execution fails:
level=error msg="podLatencyQuantilesMeasurement: P99 Ready latency (0.50s) higher than configured threshold: 100ms"
Testkube uploads the artifacts whether the execution passes or fails:
metrics/podLatencyMeasurement-pod-density.jsonhas the latencies of every pod.metrics/podLatencyQuantilesMeasurement-pod-density.jsonhas the P50, P95, P99, maximum and average latency of each pod condition.metrics/jobSummary.jsonhas the duration, settings and result of the job, and the Kubernetes version and node count of the cluster.metrics/kube-burner.lphas the same results as custom metrics for Insights.
Custom metrics in Insights
The JSON files in the artifacts are kube-burner's own format. To chart the results across executions, the Convert metrics to line protocol step turns them into custom metrics: it writes InfluxDB Line Protocol to metrics/kube-burner.lp, and Testkube ingests the file when it uploads the artifacts. The upload logs a Processing InfluxDB line protocol report: metrics/kube-burner.lp line when it detects the file.
The script writes one record per pod condition, with the condition and the job name as tags, and one record for the job:
kube_burner_pod_latency_ms,job=pod-density,condition=PodScheduled p50=356.0,p95=753.0,p99=753.0,max=860.0,avg=415.0
kube_burner_pod_latency_ms,job=pod-density,condition=Ready p50=0.0,p95=1000.0,p99=1000.0,max=1000.0,avg=400.0
kube_burner_job,job=pod-density elapsed_seconds=4.0,iterations=10i,qps=5i,nodes=1i,passed=1i
This creates the following metrics in Insights:
| Metric | Identity | Value |
|---|---|---|
kube_burner_pod_latency_ms_p50, _p95, _p99, _max, _avg | job, condition | Latency quantiles of each pod condition, in milliseconds |
kube_burner_job_elapsed_seconds | job | Duration of the job |
kube_burner_job_iterations, kube_burner_job_qps | job | Settings of the run, to tell runs of different sizes apart |
kube_burner_job_nodes | job | Number of nodes in the cluster |
kube_burner_job_passed | job | 1 when the run met the latency thresholds, 0 when it did not |
In Insights, the metrics appear under Custom Report Metrics. Segment a latency metric by condition to compare, for example, the scheduling and ready latencies across executions.
To follow them together, add them to an Insights board. The board below has these analyses, each filtered to the kube-burner-pod-density Workflow:
- The pass/fail ratio of the Workflow, which shows how often the run met its latency threshold.
kube_burner_job_iterationswith thesumaggregate, for the number of pods created per day.kube_burner_pod_latency_ms_p99with themaxaggregate, andkube_burner_pod_latency_ms_avgwith theavgaggregate, both segmented bycondition.kube_burner_pod_latency_ms_p99filtered toconditionPodScheduled, which kube-burner measures in milliseconds rather than whole seconds.kube_burner_job_elapsed_seconds, for the duration of the job.

kube-burner computes most pod condition latencies from the condition timestamps of the pods, which Kubernetes records in whole seconds. Small runs on a fast cluster can therefore show a latency of 0, and the values move in steps of 1000 milliseconds.
To chart more of kube-burner's output, extend the script: for example, read other measurement files from /data/metrics, or add tags such as the cluster name. Keep tag values to a small, fixed set, as the custom metrics page recommends.
Going further
- Use one of the kube-burner example workloads, such as
api-intensiveorcrd-scale, by checking out the kube-burner repository withcontent.gitand passing the path of its configuration file to--config. Extend the ClusterRole with the objects the workload creates. - Add Prometheus metrics to the run by adding a
metricsprofile and the URL of your Prometheus server to themetricsEndpointssection. kube-burner then indexes API server, etcd and kubelet metrics for the time window of the test. - Run the Workflow on a schedule, or after a cluster or network plugin upgrade with a Test Trigger, to catch regressions in cluster performance.