From 52493f181ae67e6308660a96f2a0ad62397752a1 Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Mon, 22 Nov 2021 11:52:22 -0500 Subject: [PATCH] Add section about the k6 load tester As suggested here: https://cloud-native.slack.com/archives/C01JR4YUG4B/p1637598108108000 Signed-off-by: Julien Duchesne --- docs/gitbook/usage/webhooks.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/gitbook/usage/webhooks.md b/docs/gitbook/usage/webhooks.md index 4523712b..d883a3e9 100644 --- a/docs/gitbook/usage/webhooks.md +++ b/docs/gitbook/usage/webhooks.md @@ -253,6 +253,42 @@ to the nGrinder server and start a new performance test. the load tester will pe poll the nGrinder server for the status of the test, and prevent duplicate requests from being sent in subsequent analysis loops. +### K6 Load Tester + +You can also delegate load testing to a third-party webhook. An example of this is the [`k6 webhook`](https://github.com/grafana/flagger-k6-webhook). This webhook uses [`k6`](https://k6.io/), a very featureful load tester, to run load or smoke tests on canaries. For all features available, see the source repository. + +Here's an example integrating this webhook as a `pre-rollout` step, to load test a service before any traffic is sent to it: + +```yaml +webhooks: +- name: k6-load-test + timeout: 5m + type: pre-rollout + url: http://k6-loadtester.flagger/launch-test + metadata: + script: | + import http from 'k6/http'; + import { sleep } from 'k6'; + export const options = { + vus: 2, + duration: '30s', + thresholds: { + http_req_duration: ['p(95)<50'] + }, + ext: { + loadimpact: { + name: '/', + projectID: , + }, + }, + }; + + export default function () { + http.get('http://-canary.:80/'); + sleep(0.10); + } +``` + ## Integration Testing Flagger comes with a testing service that can run Helm tests, Bats tests or Concord tests when configured as a webhook.