Error while deploying K6 on Kubernetes

I am using the following guide to deploy K6 and run tests on a Kubernetes Cluster.
https://k6.io/blog/running-distributed-tests-on-k8s/

I can notice that it is not working properly. All the pods created by jobs are failing. The error message is :

level=error msg="The moduleSpecifier \"/test//home/ubuntu/perfomance/index.js\" couldn't be found on local disk.

There is no directory called /test. I am not able to get it.

Hi @kapil,

That tutorial is a bit outdated but mostly correct and should continue to work, so some additional info is needed before I can help you. What command have you used to create a configmap and how does the configmap look like now? E.g. if you use more than one .js file for your scripting, all of them must be present in the configmap: this is not the case described in tutorial but it is described in the README, Mutli-file tests section. Also, how did you specify your yaml?

Could you provide these please? Thanks.

Hi. The command I used to create configmap is:

kubectl create configmap {map-name} --from-file index.js

The kubectl configmap describe cmd is working. The file index.js calls multiple .js files from inside. So in order to include all of them can I use

kubectl create configmap scenarios-test --from-file=./{my-repo-dir}

Will this work?

If I need to execute those tests using the K6 docker image, can I use

---
apiVersion: k6.io/v1alpha1
kind: K6
metadata:
  name: k6-sample
spec:
  parallelism: 4
  script:
    localFile: /test/test.js
  runner:
    image: {latest k6 docker image}

My repo structure goes like this. An index.js file on the root folder which calls different .js files from other folders. Could you please help me on this?

It should work :slightly_smiling_face: If it doesn’t, please let me know the details.

As for the localFile, you can use that too of course but it is not the recommended way: you need to build your own custom image for that and it was added for the cases when neither Configmap nor VolumeClaim can be used.