kubectl kuttl test leaves garbage kubeconfig file around
What happened:
After kubectl kuttl test runs, a kubeconfig file appears in current directory.
What you expected to happen:
No garbage left behind.
How to reproduce it (as minimally and precisely as possible):
$ cat kuttl-test.yaml
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
testDirs:
- ./empty
$ ls kubeconfig
ls: kubeconfig: No such file or directory
$ kubectl kuttl test --namespace blah
=== RUN kuttl
harness.go:457: starting setup
harness.go:248: running tests using configured kubeconfig.
harness.go:285: Successful connection to cluster at: https://kubernetes.docker.internal:6443
harness.go:353: running tests
harness.go:74: going to run test suite with timeout of 30 seconds for each step
harness.go:365: testsuite: ./empty has 0 tests
=== RUN kuttl/harness
=== CONT kuttl
harness.go:399: run tests finished
harness.go:508: cleaning up
harness.go:563: removing temp folder: ""
--- PASS: kuttl (1.22s)
--- PASS: kuttl/harness (0.00s)
PASS
$ ls -l kubeconfig
-rw-r--r-- 1 marcin staff 5484 Jun 9 12:24 kubeconfig
$
Anything else we need to know?:
👋🏻
Environment:
- Kubernetes version (use
kubectl version):
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:23:52Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:15:20Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
- KUTTL version (use
kubectl kuttl version):KUTTL Version: version.Info{GitVersion:"0.10.0", GitCommit:"fc8c0f2", BuildDate:"2021-05-19T13:16:03Z", GoVersion:"go1.16.3", Compiler:"gc", Platform:"darwin/amd64"} - Cloud provider or hardware configuration: my laptop, docker for mac
- OS (e.g. from /etc/os-release): MacOS
- Kernel (e.g.
uname -a):Darwin Marcins-MBP 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64 - Install tools:
krew
scheduling for the next release... thank you sir!
A related issue is that a hardcoded static kubeconfig filename apparently causes concurrent kuttl runs in the same directory to step on each other's toes.
To add, the kubeconfig file is created even if we provide a non-kuttl-managed cluster via KUBECONFIG environment var (it creates a copy of $KUBECONFIG).