k6-operator
k6-operator copied to clipboard
Starter doesn’t work in an IPv6 cluster
Brief summary
In an IPv6 cluster, the starter pod logs this error:
curl: (3) IPv6 numerical address used in URL without brackets
k6-operator version or image
latest
K6 YAML
apiVersion: k6.io/v1alpha1
kind: K6
metadata:
name: load-test
namespace: load-testing
spec:
parallelism: 100
script:
configMap:
name: load-test
file: load-test.js
separate: true
runner:
resources:
requests:
cpu: 1
memory: 4G
Other environment details (if applicable)
No response
Steps to reproduce the problem
Create an IPv6 cluster on AWS EKS, deploy the operator inside and start a test.
Expected behaviour
The test run as expected.
Actual behaviour
The test doesn’t start because the operator doesn’t seem to handle IPv6.
Looks like it's a rather well-known issue for IPv6 in general and specifically for curl.
At first glance, seems like a quick fix with adding brackets to curl command. But curl doesn't seem to support brackets with IPv4 so we'll need to check first if it's IPv4 or IPv6; maybe before Job creation, in https://github.com/grafana/k6-operator/blob/5cec748534424741fbea0e1875218b56bf5af670/controllers/k6_start.go#L71-L80
Either way, thanks for opening this, @yann-soubeyrand!
I have the same issue as described earlier i.e. I try to start a test on an ipv6-only EKS-cluster, but the k6-sample-starter-pod fails to start due to following error:
curl: (3) IPv6 numerical address used in URL without brackets
For now I was able to go around this issue by creating a custom-image by using following line:
parts = append(parts, fmt.Sprintf("curl -g --retry 3 -X PATCH -H 'Content-Type: application/json' http://[%s]:6565/v1/status -d '%s'", hostname, req))
in NewStartContainer and NewStopContainer-function (please note that I needed to provide also this -g globbing option)
If there is away to do this globally i.e. supporting both ipv4 and ipv6, I would be more than happy to try that out :)
Let’s go ahead 🙆
@pasi-romo-idealo
If there is away to do this globally i.e. supporting both ipv4 and ipv6, I would be more than happy to try that out :)
I tested it by adding net package and then using net.JoinHostPort()
, which wraps the hostname in square braces if it's a literal IPv6 address.
parts = append(parts, fmt.Sprintf("curl --retry 3 -X PATCH -H 'Content-Type: application/json' http://%s/v1/status -d '%s'", net.JoinHostPort(hostname, "6565"), req))
I tested it on my local and it supports both IPv4 and IPv6.