Reputation:
I am setting KUBECONFIG
variable, but kubectl is not using this variable and instead using the default config file.
Setting variable as below -
$export KUBECONFIG=./my-k8s-token.config
next am running get pods as below -
$ kubectl.exe get pods -v 8
I1211 22:08:39.175597 1920 loader.go:359] Config loaded from file C:\Users\myuserhome/.kube/config
I1211 22:08:39.186378 1920 round_trippers.go:416] GET https://kubernetes.docker.internal:6443/api/v1/namespaces/default/pods?limit=500
I1211 22:08:39.187586 1920 round_trippers.go:423] Request Headers:
As you can see above, kubectl is still using the default config file: C:\Users\myuserhome/.kube/config
.
How can i fix this. How can i make kubectl read the config file from KUBECONFIG variable.
Note: If you are wondering why there is .exe extension for kubectl, the answer is I am using WSL2 with Ubuntu.
Upvotes: 4
Views: 5370
Reputation:
I could solve the issue by using kubectl
which i installed using offical documentation - https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management.
Now on using kubectl instead of kubectl.exe I am able to use KUBECONFIG env variable.
Upvotes: 3