c-bata / kube-prompt

An interactive kubernetes client featuring auto-complete.
MIT License
1.79k stars 134 forks source link

Fails if .kube/config has another name #22

Closed tarekmehrez closed 5 years ago

tarekmehrez commented 6 years ago

I have 3 different cluster configs, all set in KUBECONFIG. All have different names than just config kube-prompt fails when I try to get a certain pod or service

>>> get pods panic: stat /Users/tarekmehrez/.kube/config: no such file or directory

goroutine 36 [running]:
github.com/c-bata/kube-prompt/kube.NewClient(0x0)
    /Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:29 +0x140
github.com/c-bata/kube-prompt/kube.getClient(0x0)
    /Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:14 +0x2e
github.com/c-bata/kube-prompt/kube.fetchPods()
    /Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:177 +0x72
created by github.com/c-bata/kube-prompt/kube.getPodSuggestions
    /Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:183 +0x39

Is there a way that this might work by checking the config files set in the KUBECONFIG env var? Thanks

boazj commented 5 years ago

Just tested it out with the latest release and I cannot reproduce it. I've replicated my config file to config-test, changed the context name and the default namespace and set KUBECONFIG to be config-test getting the pods with and without KUBECONFIG returned the expected result for config & config-test respectively to their default (different) namespace

Which version of kube-prompt are you using? v1.0.4 included a go-client update from version 2.0.0 to 8.0.0 and removal (e4d11f1) of explicitly setting "loadingRules.ExplicitPath = clientcmd.RecommendedHomeFile" which override KUBECONFIG resolution.

c-bata commented 5 years ago

Thanks. As @boazj said, this problem seems to be fixed at https://github.com/c-bata/kube-prompt/pull/20.

@tarekmehrez Could you reply the version or commit revision if you reproduce this. You can check it, just running.

$ kube-prompt
kube-prompt v1.0.4 (rev-61ddcfd)
Please use `exit` or `Ctrl-D` to exit this program.
>>>