A query on kubectl

4/22/2020

I have created a k8s cluster on GCP. And then I installed kubectl tool and Google Cloud SDK locally. Other than that I have done no extra configuration. I just added kubectl location to system path.

Now when I do 'kubetcl get pods', it fetches me the list of pods deployed in GCP cluster.

But how does kubectl know about that cluster? I surely didn't provide any information to it.

-- Mandroid
kubectl
kubernetes

2 Answers

4/22/2020

If you want to use kubectl to interact with the cluster, then you need to update cluster details in kube config. The config file is probably have a file named config in the $HOME/.kube directory.

Please refer here

-- Renjith Kathirolil
Source: StackOverflow

4/22/2020

Kubectl uses a Kubeconfig file which has a server attribute with the IP or hostname of the Kubernetes API server hosted in GCP.

By default, kubectl looks for a file named config in the $HOME/.kube directory. You can specify other kubeconfig files by setting the KUBECONFIG environment variable or by setting the --kubeconfig flag.

From the docs here gcloud command automatically updates the kubeconfig file with correct API Server address and other parameters.

-- Arghya Sadhu
Source: StackOverflow