Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

k6: k6 --out json - open ./test.json: permission denied

Tags:

kubernetes

k6

I have created a kubernetes cluster on digitalocean, and I have deployed k6 as a job on the kubernetes cluster.

apiVersion: batch/v1
kind: Job
metadata:
  name: benchmark
spec:
  template:
    spec:
      containers:
      - name: benchmark
        image: loadimpact/k6:0.29.0
        command: ["k6", "run", "--vus", "2", "--duration", "5m", "--out", "json=./test.json", "/etc/k6-config/script.js"]
        volumeMounts:
        - name: config-volume
          mountPath: /etc/k6-config
      restartPolicy: Never
      volumes:
      - name: config-volume
        configMap:
          name: k6-config

this is how my k6-job.yaml file look like. After deploying it on the kubernetes cluster I have checked the pod's logs. It is showing a permission denied error. level=error msg="open ./test.json: permission denied"

How to solve this issue?

like image 888
Devi varalakshmi Tangilla Avatar asked Oct 18 '25 13:10

Devi varalakshmi Tangilla


1 Answers

The k6 Docker image runs as an unprivileged user, but unfortunately the default work directory is set to /, so it has no permission to write there.

To work around this consider changing the JSON output path to /home/k6/out.json, i.e.:

command: ["k6", "run", "--vus", "2", "--duration", "5m", "--out", "json=/home/k6/test.json", "/etc/k6-config/script.js"]

I'm one of the maintainers on the team, so will propose a change to the Dockerfile to set the WORKDIR to /home/k6 to make the default behavior a bit more intuitive.

like image 193
imiric Avatar answered Oct 20 '25 13:10

imiric



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!