Schedule k6 tests
While the k6 Operator doesn’t support scheduling k6 tests directly, you can schedule tests with the CronJob
object from Kubernetes directly. The CronJob
would run on a schedule and execute the creation and deletion of the TestRun
object.
Running these tests requires a little more setup than a standalone test run.
Create a ConfigMap
with k6 scripts
Refer to Run k6 scripts with TestRun
CRD for details on how to create a ConfigMap
with k6 scripts.
Create a ConfigMap of the YAML file for the TestRun
job
When using the make deploy
installation method, add a configMapGenerator
to the kustomization.yaml
:
configMapGenerator:
- name: <test-name>-config
files:
- <test-name>.yaml
Create a ServiceAccount
for the CronJob
For the CronJob
to be able to create and delete TestRun
objects, create a service account:
Create a CronJob
This is an example of how to define a CronJob
in a YAML file: