I have a set of clusters split between two projects, 1 and 2. Currently, need to use gcloud init
to switch between the two projects. Is there any possibility of having both projects active under the single configuration? Or, is it possible to have two configurations simultaneously active? I would hate to have to use init
every time to switch between the two. Thanks!
gcloud init
should only be used to (re)initialize gcloud
on a host. The only time I ever use it is when I install gcloud
on a new machine.
gcloud
uses a global config that can be manipulated with the gcloud config
command. IMO (I've been using GCP for 9 years) the less you use gcloud config
, the better for your experience.
I think you're much better placed specifying config explicitly with gcloud
commands.
Every gcloud
command can include e.g.:
--project=${PROJECT}
to specify the project to use--account=${ACCOUNT}
to specify the gcloud auth
'd account to use--region=${REGION}
or --zone=${ZONE}
or --location=${LOCATION}
etc.
Using gcloud
commands and explicitly setting flags to specific the project, account, location etc. makes it trivial to flip between these and often (though not always) in a more intentional way.