localFile usage with mount volumes failed

Hi, I see that we have an example to use localFile with volumeMounts
But somehow I just following the yaml format , and exec to the pod, the file that I needed is not there. I just described the pod also and there is no volume expected created. Is there any possibility of uncomplete yaml? Here is my yaml file

apiVersion: k6.io/v1alpha1
kind: K6
metadata:
  name: k6-test
spec:
  parallelism: 2
  script:
    localFile: /home/k6/index.js
  arguments: -u 2 -d 30s
  runner:
    image: myImage
    envFrom:
      - secretRef:
          name: grafana-cloud-k6-secrets
    volumes:
      - emptyDir: {}
        name: test
        configMap:
          name: k6-demo
          items:
            - key: conf.js
              path: conf.js
    volumeMounts:
      -  mountPath: /home/k6
         name: test

Is this might be related to this :
Package operator · GitHub (last pushed July 14, 2023)
GitHub - grafana/k6-operator: An operator for running distributed k6 tests. (last commit Aug 2,2023)
Latest tagged image is older than latest changes of the repo.

Hi @isma1

Welcome to the community forum :wave:

I’m not so sure what your scenario is. Do you want to use a ConfigMap, mount via VolumeClaim or localFile?

The example is for init containers with volumes. If you want a localFile (the file is already in the container), have a look at the example in https://github.com/grafana/k6-operator/blob/main/config/samples/k6_v1alpha1_k6_with_localfile.yaml.

I hope this helps :bowing_woman:

Cheers!

Welcome :wave:
Thanks for the fast response :grin:
I just try that way and it works. But the necessary is we need to access a file from outside, like a configurable file for a test scenario. Is that possible running with localFile to have volumeMounts also?

Thanks

Hi @isma1

I’m still not sure I understand the scenario.

If the file scripts are external, and not in a custom k6 docker image that you create, you should create a PVC and follow https://github.com/grafana/k6-operator/blob/main/config/samples/k6_v1alpha1_k6_with_volumeClaim.yaml.

Do you have a mix of files, some local in the docker image and some that you mount via volumeClaim? We could better advise if you can share a sanitized example of the test and where it reads the external data. And clarify if it’s the test itself that is external and the data local, or how you need to mix those.

Cheers!

Hi, I’ll share you the expected directory.
|__src
|___conf.js (this is expected come from volumeMounts configMap)

We have built the /src into the image, and we need to set a volume Mount from configMap and store it to conf.js
We need to choose the localFile way based on several consideration.

I hope it will be clear enough. :bowing_woman:

This case is solved. I tried to build the image with latest commit here GitHub - grafana/k6-operator: An operator for running distributed k6 tests. (rather than using 0.0.9) and edit the k6-operator-controller-manager deployment using new image, and then the mount is work.