Is there something like: kubectl get pods --project=PROJECT_ID
I would like not to modify my default gcloud configuration to switch between my staging and production environment.
kubectl
saves clusters/contexts in its configuration. If you use the default scripts to bring up the cluster, these entries should've been set for your clutser.
A brief overview of kubectl config
:
kubectl config view
let you to view the cluster/contexts in your configuration.kubectl config set-cluster
and kubectl config set-context
modifies/adds new entries.You can use kubectl config use-context
to change the default context, and kubectl --context=CONTEXT get pods
to switch to a different context for the current command.
You can download credentials for each of your clusters using gcloud container clusters get-credentials
which takes the --project
flag. Once the credentials are cached locally, you can use the --context
flag (as Yu-Ju explains in her answer) to switch between clusters for each command.