Hi friends.
I am requiering to edit the STAGES in the OPTIONS as I am sending the target and duration values as an argument in the runner of my configmap, as follow:
apiVersion: k6.io/v1alpha1
kind: K6
metadata:
name: k6-sample
namespace: k6-operator-system
spec:
parallelism: 2
script:
configMap:
name: buyer-simulation
file: archive.tar
arguments: --out statsd --env K6_STATSD_ADDR=newrelic-statsd.newrelic:80 --env K6_STATSD_ENABLE_TAGS=true
runner:
env:
- name: CLIENTID
value: "client_id"
- name: CLIENTSECRET
value: "client_secret"
- name: RPS
value: "5"
- name: DURATION
value: "60s"
On another side, in my main.js I capture the values as follow:
const inputStages = {
target : `${__ENV.RPS}`,
duration : `'${__ENV.DURATION}'`
}
stage = JSON.parse(inputStages)
export const options = {
setupTimeout: '120s',
scenarios: {
post_something: {
executor: 'ramping-arrival-rate',
startTime: '1s',
startRate: 1,
timeUnit: '1s',
stages: stage,
such solution did not work, throwing the error when I launch the command “k6 archive main.js”, which is totally neccesary to wrap or zip all the files imported on my main.js :
syntaxError: invalid character 'o' looking for beginning of value
at parse (native)
But I think that a good approach is being able to edit the options with “exec” library imported from k6/execution
exec.test.options.scenarios.post_something.stages[0].target
But as many of you know, this is read only objetc.
¿what can I do?
PD: My purpose is to allow the developers be able to build their own target and duration, by a tool that I already have set named Rundeck, which is very useful to create basic forms and pass the values through a python script that overrides the parameters into my configmap , ready to be used by my k6 k8s operator
It’s fancy.
thank you all!