kubernetes-event-exporter icon indicating copy to clipboard operation
kubernetes-event-exporter copied to clipboard

Use KUBECONFIG env variable if present

Open sandipb opened this issue 3 years ago • 2 comments

sandipb avatar May 27 '22 10:05 sandipb

I'm not sure about the problem you are seeing, because I do this kind of thing in testing and it works as-is:

KUBECONFIG=~/.kube/config ./kubernetes-event-exporter -conf k23r-stdout.yaml

So it does seem to honor the KUBECONFIG at least in regard to finding the kubeconfig used to setup the event watcher. I think the machinery for that is built into the upstream client-go code.

xmcqueen avatar Jun 25 '22 17:06 xmcqueen

You are using the default KUBECONFIG. Even if you dont set that env variable, that will work. However, if your KUBECONFIG is anything other that the default path, it will not work. You can look at the part of the code I am changing. Currently, it reads the path you are mentioning anyway:

return clientcmd.BuildConfigFromFlags("", filepath.Join(os.Getenv("HOME"), ".kube", "config"))

sandipb avatar Jun 26 '22 18:06 sandipb