Kubectl how to connect to config file

7/30/2019

I've setup a K8s cluster and got the config file which I have placed in the username/.kube directory

I can't seem to workout how to link my Powershell Kubectl to this config file by default. For instance if I try and run the following command I don't get the cluster I've setup.

kubectl config get-contexts

If however, I run the following command, I do get a list of my current nodes

kubectl --kubeconfig="cluster-kubeconfig.yaml" get nodes
-- Rutnet
kubectl
kubernetes

1 Answer

7/30/2019

Copy contents of cluster-kubeconfig.yaml file to $HOME/.kube/config

This will be the default kubernetes context file.

You can also override and point to any other custom kubernetes context using

 $Env:KUBECONFIG=("/path/to/cluster-kubeconfig.yaml")

as mentioned here.

For more info check this out.

Hope this helps.

-- mchawre
Source: StackOverflow