Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Google Cloud Project Id from a container in Google hosted Kubernetes cluster

Detect Google Cloud Project Id from a container in Google hosted Kubernetes cluster.

When connecting to BigTable; I need to provide the Google Project Id. Is there a way to detect this automatically from within K8s?

like image 483
brent Avatar asked Sep 04 '17 07:09

brent


People also ask

How do I find my GCP cluster ID?

To view your clusters, go to the Google Kubernetes Engine page in the Google Cloud console. To see more information about a cluster, select the cluster from the list.

How can I get cluster ID in Kubernetes?

To find out the Kubernetes cluster ID or NAME , get a list of Kubernetes clusters from the folder or detailed information about the Kubernetes cluster.

Which of the following command is used to get detailed information of a Kubernetes cluster?

kubectl get − This command is capable of fetching data on the cluster about the Kubernetes resources. kubectl logs − They are used to get the logs of the container in a pod.


1 Answers

In Python, you can find the project id this way:

import google.auth
_, PROJECT_ID = google.auth.default()

The original question didn't mention what programming language was being used, and I had the same question for Python.

like image 179
b4hand Avatar answered Oct 30 '22 16:10

b4hand