What is the purpose of gcloud config set container/cluster cluster_name?

8/28/2018

I have two GKE clusters: c1, c2,

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

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

-- gacopu
google-cloud-platform
google-kubernetes-engine
kubectl
kubernetes

1 Answer

8/28/2018

The gcloud container cluster commands are for administrating your clusters from a GCP perspective, e.g. adding another node-pool for a GKE kubernetes cluster using the node-pools create command.

Controlling which cluster is used for kubectl is done via .kube/config file which has a so called current-context. There is the kubectx/kubens project that provides some nice helpers to allow switching between clusters (and namespaces) more easily.

-- Andreas Jägle
Source: StackOverflow