How to start k6 from a webservice endpoint in k8s?

Hi, i am new to k6 (and not an k8s expert) so sorry if my question is not clear or stupid.

We would like to run k6 load tests inside a kubernetes cluster without starting any test after deployment. The pod should contain many different tests (test_api1_shorttest.js, test_api1_longtest.js, test_api2_shorttest.js…). Now we could like to start a concrete test by hitting a rest endpoint (via curl).

Is this possible (to call k6 from an endpoint) and are there any examples how to archieve this (or hints or best practices)?

I came more from a Java background and only have some Spring Boot ideas for the Endpoints, but not know how to call k6 from Java. Probably there are better ways?

Hi @k6beginner,

Firstly, have you seen k6-operator? That’s likely the quickest to way to run k6 in Kubernetes at the moment. It does assume that you already have a cluster running.

For multiple scripts, you can put all of them into PVC and then start whichever script you need by applying different K6 specs.

As for endpoints, you might want to check Kubernetes API docs - there are quite a few options there :slightly_smiling_face:

Let me know if that helps!