Reputation: 1024
I understand kubectl gets the kubeconfig file in the order
--kubeconfig
KUBECONFIG=
~/.kube/config
But is there a way to get the kubeconfig path/file details from the kubectl which one being currently used?
Something like kubectl config path
Upvotes: 8
Views: 14685
Reputation: 18371
Question: But is there a way to get the kubeconfig path/file details from the kubectl which one being currently used?
Yes, you can run any kubectl
command with verbose
level 6+ to see the kubeconfig
in use.
kubectl get pod -v6
I0629 04:48:25.050954 14444 loader.go:379] Config loaded from file: /home/ps/.kube/config
I0629 04:48:25.146072 14444 round_trippers.go:445] GET https://kubemaster:6443/api/v1/namespaces/default/pods?limit=500 200 OK in 10 milliseconds
No resources found in default namespace.
Few examples demonstrating the same:
kubectl get pod -v6 2>&1 |awk '/Config loaded from file:/{print $NF}'
/home/ps/.kube/config
Changed thekubeconfig
to /tmp/config
export KUBECONFIG=/tmp/config
kubectl get pod -v6 2>&1 |awk '/Config loaded from file:/{print $NF}'
/tmp/config
Remove the awk
command to see the whole output.
Windows output:
Upvotes: 20