k9s won't start if the namespace/context in the current kubeconfig is different from the previously one used by k9s.
in one shell I have the KUBECONFIG variable set to a different file.
use k9s
close k9s
in another shell, KUBECONFIG is pointing to ~/.kube/config which holds completely different cluster/ctx/namespace
start k9s
returns an error, listing the previous context. (called "internal" in this case)
k9s
panic: context "internal" does not exist
goroutine 1 [running]:
github.com/derailed/k9s/internal/k8s.(*apiServer).restConfigOrDie(...)
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/k8s/api.go:145
github.com/derailed/k9s/internal/k8s.(*apiServer).dialOrDie(0xc0002a7810, 0xc00036d0f0, 0xc00055f230)
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/k8s/api.go:84 +0x106
github.com/derailed/k9s/internal/k8s.(*apiServer).supportsMxServer(0xc0002a7810, 0xc0002a7810)
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/k8s/api.go:171 +0x43
github.com/derailed/k9s/internal/k8s.InitConnectionOrDie(...)
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/k8s/api.go:70
github.com/derailed/k9s/internal/cmd.initK9s()
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/cmd/root.go:67 +0x18e
github.com/derailed/k9s/internal/cmd.run(0x3190dc0, 0x31bce00, 0x0, 0x0)
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/cmd/root.go:146 +0x67
github.com/spf13/cobra.(*Command).execute(0x3190dc0, 0xc00003a020, 0x0, 0x0, 0x3190dc0, 0xc00003a020)
/Users/fernand/go_wk/derailed/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0x3190dc0, 0x10056ef, 0xc00009e058, 0x0)
/Users/fernand/go_wk/derailed/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2c0
github.com/spf13/cobra.(*Command).Execute(...)
/Users/fernand/go_wk/derailed/pkg/mod/github.com/spf13/[email protected]/command.go:800
github.com/derailed/k9s/internal/cmd.Execute()
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/internal/cmd/root.go:123 +0x2e
main.main()
/Users/fernand/go_wk/derailed/src/github.com/derailed/k9s/main.go:25 +0x20
explicitly state which kubeconfig and context to use when starting k9s
k9s --kubeconfig myconfig --context mycontext
@mimizone First off thank you for the excellent report!
I think this ties in with #111. Though K9s should have figured this out and launch from the current context in this case. I'll fix on the next drop!
It would be also good that k9s starts with the namespace specified in the current context (if applicable).
@mimizone @matthyx. I think this is now fixed in 0.2.5. Please reopen if not Tx!
Fixed for me, thx!
Most helpful comment
@mimizone First off thank you for the excellent report!
I think this ties in with #111. Though K9s should have figured this out and launch from the current context in this case. I'll fix on the next drop!