Load-test rig: k6 swarm script + in-cluster target drone

This commit is contained in:
Adam Carr
2026-09-19 18:16:57 -07:00
parent e46cf90e69
commit 8451333c3a
6 changed files with 337 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
apiVersion: v1
kind: Namespace
metadata:
name: loadtest
---
apiVersion: v1
kind: ConfigMap
metadata:
name: k6-script
namespace: loadtest
data:
test.js: |
// Generic load generator. Configured by env:
// TARGET_URL - full URL to hit
// VUS - virtual users per pod (default 20)
// DURATION - k6 duration string (default "60s")
import http from 'k6/http';
import { check, sleep } from 'k6';
const target = __ENV.TARGET_URL || 'http://example.com';
const vus = parseInt(__ENV.VUS || '20');
const duration = __ENV.DURATION || '60s';
export const options = {
stages: [
{ duration: '10s', target: vus },
{ duration: duration, target: vus },
{ duration: '5s', target: 0 },
],
thresholds: { http_req_failed: ['rate<0.01'] },
noConnectionReuse: false,
};
export default function () {
const res = http.get(target, { timeout: '10s' });
check(res, { 'status 2xx/3xx': (r) => r.status < 300 });
sleep(1 / vus * 10);
}