<p>I have two GKE clusters: c1, c2,</p>

<p>I use <code>gcloud config set container/cluster c1</code> to set the default cluster to c1, after that I run <code>kubectl run</code>, seems the new pods still created in c2.</p>

<p>how can i switch to c2? and what is the purpose of <code>gcloud config set container/cluster cluster_name</code>?</p>

gacopu
<p>The <code>gcloud container cluster</code> commands are for administrating your clusters from a GCP perspective, e.g. adding another node-pool for a GKE kubernetes cluster using the <a href="https://cloud.google.com/sdk/gcloud/reference/container/node-pools/create" rel="nofollow noreferrer">node-pools create command</a>.</p>

<p>Controlling which cluster is used for kubectl is done via .kube/config file which has a so called <code>current-context</code>. There is the <a href="https://github.com/ahmetb/kubectx" rel="nofollow noreferrer">kubectx/kubens project</a> that provides some nice helpers to allow switching between clusters (and namespaces) more easily.</p>
