Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

kubernetes

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.

like image 655
poiuytrez Avatar asked Apr 15 '16 15:04

poiuytrez


1 Answers

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.

like image 77
Yu-Ju Hong Avatar answered Oct 19 '22 17:10

Yu-Ju Hong