Skip to content

Instantly share code, notes, and snippets.

@moio
Created July 31, 2025 14:04
Show Gist options
  • Select an option

  • Save moio/39dcf3ee847773839e3375fd3a9d71e7 to your computer and use it in GitHub Desktop.

Select an option

Save moio/39dcf3ee847773839e3375fd3a9d71e7 to your computer and use it in GitHub Desktop.
Run k6 from a pod interactively

Running k6 interactively from a pod in the tester cluster

Set local paths:

export KUBECONFIG=/path/to/tester.cluster.kubeconfig
export K6_TESTS_DIR=./k6/tests

Create a volume and pod

kubectl apply -f - <<EOF
$(kubectl create configmap k6-scripts-config --from-file=$K6_TESTS_DIR --dry-run=client -o yaml)
---
apiVersion: v1
kind: Pod
metadata:
  name: k6
spec:
  containers:
  - name: k6
    image: grafana/k6
    command: ["/bin/sh", "-c", "sleep infinity"]
    volumeMounts:
    - name: k6-scripts-volume
      mountPath: /home/k6/scripts
  volumes:
  - name: k6-scripts-volume
    configMap:
      name: k6-scripts-config
  restartPolicy: Never
EOF

Connect to the pod

kubectl exec -it k6 -- /bin/sh

Run k6 from inside the pod

k6 run \
  -e ENV=...
  scripts/my_script.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment