Is there a way to retrieve the Application Default API key programmatically inside a k8s pod deployed to GKE?

9/2/2017

I want to use Python HTTP libraries to read Google Cloud storage objects using URIs with an API key param:

https://cloud.google.com/storage/docs/xml-api/reference-uris

This code will be running inside a Kubernetes pod deployed on GKE.

Is there a way I can programmatically retrieve the Application-default API key to append to the URIs?

The reason I want to use URIs and not the client library is because I need to make HTTP Range requests to retrieve particular byte ranges.

-- user553965
google-kubernetes-engine
python

1 Answer

9/7/2017

Is there a reason why you're not using the official Python client library (https://googlecloudplatform.github.io/google-cloud-python/) with Google Cloud Service Account (a .json key file)? Ideally you should not need to prepare and make HTTP calls with credentials yourself, that's what client libraries are for.

There's a tutorial at https://cloud.google.com/container-engine/docs/tutorials/authenticating-to-cloud-platform showing how to create the credentials, import to Kubernetes and use in the Pod.

-- AhmetB - Google
Source: StackOverflow