Is there a way to specific the google cloud platform project for kubectl in the command?

4/15/2016

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.

-- poiuytrez
kubernetes

2 Answers

4/15/2016

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:

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.

-- Yu-Ju Hong
Source: StackOverflow

4/17/2016

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.

-- Robert Bailey
Source: StackOverflow