How to delete k6 jobs in kubernetes automatically?

Hi!

I’m using k6 to run tests on k8s

I want to know If is possible to configure the runner to remove / clean up the jobs automatically (i cant run kubectl delete) like using ttlSecondsAfterFinished

Thanks

Hello, and welcome to the forum! You can include the cleanup: post option in your custom resource.

Here is an example including the option:

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: run-k6-with-realtime
spec:
  parallelism: 4
  # Removes all resources upon completion
  cleanup: post
  script:
    configMap:
      name: my-test
      file: test.js
  arguments:  -o experimental-prometheus-rw

This example is from the Running distributed tests guide in the documentation site.

Thanks a lot mate! Works as expected!

1 Like