kubectl-doctor
kubectl-doctor copied to clipboard
Failing when there are multiple contexts in KUBECONFIG env variable.
Having multiple contexts in the environment variable KUBECONFIG
fails when it tries to scan the provided namespace. The result is exactly the same passing the -n my_namespace
flag or providing a specific context.
$ kubectl doctor
WARN[0000] discovered a list of kubeconfigs & will respect current-context! kubeconfiglist="[/Users/tty0/.kube/config /Users/tty0/.kube/config-dguiaf-prod /Users/tty0/.kube/config-dguiaf-rancher /Users/tty0/.kube/config-dguiaf-dev /Users/tty0/.kube/config-dguiaf-test /Users/tty0/.kube/k3s]"
INFO[0000] Going for a full scan as no flags are set!
INFO[0000] Retrieving necessary clientset for targeted k8s cluster.
INFO[0000]
INFO[0000] Fetched namespaces: []
INFO[0000]
error: namespace must be specified/retrieved properly!
$: kubectl get namespaces
NAME STATUS AGE
default Active 9h
kube-node-lease Active 9h
kube-public Active 9h
kube-system Active 9h
monitoring Active 9h
$: echo $KUBECONFIG
/Users/tty0/.kube/config:/Users/tty0/.kube/config-prod:/Users/tty0/.kube/config-rancher:/Users/tty0/.kube/config-dev:/Users/tty0/.kube/config-test:/Users/tty0/.kube/k3s
$: kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T18:49:28Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3+k3s1", GitCommit:"974ad30be7b7b15f695d88e46ffa96a4d43b2370", GitTreeState:"clean", BuildDate:"2020-10-16T00:18:50Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/arm64"}