Search code examples
kubernetesgoogle-cloud-platformgoogle-kubernetes-enginegoogle-cloud-bigtable

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?


Solution

  • Google has some libraries for this too: ServiceOptions.getDefaultProjectId

    https://googleapis.github.io/google-cloud-java/google-cloud-clients/index.html

    https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java

    https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core