kuttl icon indicating copy to clipboard operation
kuttl copied to clipboard

Issue running kuttl in a gitlab runner

Open max-l-f opened this issue 4 years ago • 7 comments

Hello, I'm trying to run kuttl in CI context using gitlab CI/CD. In this context kuttl is launched in a gitlab runner running in a kubernetes cluster and I want to run my tests in a different kubernetes cluster. When launching the kubectl kuttl test command in this context I'm getting this error: $ kubectl kuttl test === RUN kuttl harness.go:457: starting setup harness.go:248: running tests using configured kubeconfig. harness.go:508: cleaning up harness.go:563: removing temp folder: "" harness.go:589: fatal error getting client: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory --- FAIL: kuttl (0.00s) FAIL

Other kubectl commands are working fine. The tests pass when launched with the same docker image and using the same kubeconfig but launched using docker desktop.

Do you have any idea how to solve my problem ?

Thank you !

max-l-f avatar Nov 19 '21 14:11 max-l-f

I assume by reading the code that when kuttl is run from a kubernetes pod it tries to deploy the tests on the same cluster but that's not what I want to do. Does someone have an idea about how to fix that, I don't think it should work like that.

max-l-f avatar Nov 24 '21 13:11 max-l-f

Hi @max-l-f, could you share your kuttl-test.yaml? This can be useful to understand what is happening. Also, what KUTTL version are you using?

iblancasa avatar Nov 26 '21 08:11 iblancasa

Hi, kuttl-test.yaml:

apiVersion: kuttl.dev/v1beta1 kind: TestSuite testDirs:

  • ./test/integration

kuttl version: 0.11.1

I forced the kuttl step to run on a docker engine instead of kubernetes and it works fine but I still have the issue when it runs in a kubernetes pod.

max-l-f avatar Nov 26 '21 08:11 max-l-f

hmm... we run kuttl in docker images for operator sdk scorecard. I think we need more information but will take a look

kensipe avatar Apr 14 '22 13:04 kensipe

ah... @max-l-f I believe the scorecard is running in the same cluster and that is assumed for sure. So you are running in 1 cluster and wanting to test another cluster. I'm not sure we have ever looked at that.. that detail is likely the important part of this submission. Thanks for the report!

kensipe avatar Apr 14 '22 13:04 kensipe

yes exactly I can't choose the cluster from which the test are launched

max-l-f avatar Apr 14 '22 14:04 max-l-f

This workaround seems to work for me though I don't love it

# mkdir -p /var/run/secrets/kubernetes.io/serviceaccount      
# echo "not-actually-used" > /var/run/secrets/kubernetes.io/serviceaccount/token
# KUBECONFIG=~/.kube/config kuttl test

dweebo avatar Jun 29 '22 17:06 dweebo