I have multiple k6 scripts deployed in the kubernetes cluster and all the scripts are accessing an endpoint my manager wants that I should not use the endpoint in each script individually rather I should keep all the endpoints in a single configuration file and different k6 scripts should take the url from there because in my project we have different spring batch jobs which are using the same endpoint so he doent want me to specify the endpoint in the individual script. I tried searching around it but didnt find anything. It would be great help if someone can help me out.
I have scripts like in the below image and the scripts will keep adding how can I access the endpoint from one single file? Is it possible?
If I understand your issue correctly, I have something similar for running same script in different environments with username, password different per env. There may be better ways to do but this works for my case.
Depending how you are running K6 script you can define an environment variable “endpoint1=https:/some.url.com” and use this in your script as “page.goto(__ENV.endpoint1)”
Locally I am testing with a docker image, so I have these env variables defined in a file and I use them as “docker run --env-file <that_environment_file> …other docker options…”
For production, I am using K6 Operator on a Kubernetes cluster, so I use similar environment variables in the manifest.