gacopu
gacopu

Reputation: 646

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

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?

Upvotes: 0

Views: 1275

Answers (2)

chengxuyuan9527
chengxuyuan9527

Reputation: 37

If you have multiple clusters, you can set a default cluster for the kubectl command-line tool.

To set a default cluster for gcloud commands, run the following command:

gcloud config set container/cluster CLUSTER_NAME

Upvotes: 0

Andreas Jägle
Andreas Jägle

Reputation: 12260

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.

Upvotes: 1

Related Questions