<p>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.</p>

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

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

Mandroid
<p>Kubectl uses a <a href="https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/" rel="nofollow noreferrer">Kubeconfig file</a> which has a <code>server</code> attribute with the IP or hostname of the Kubernetes API server hosted in GCP.</p>

<p>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.</p>

<p>From the docs <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl" rel="nofollow noreferrer">here</a> gcloud command automatically updates the kubeconfig file with correct API Server address and other parameters.</p>
