【问题标题】:Is there a way to retrieve the Application Default API key programmatically inside a k8s pod deployed to GKE?有没有办法在部署到 GKE 的 k8s pod 中以编程方式检索应用程序默认 API 密钥?
【发布时间】:2017-09-02 18:39:35
【问题描述】:

我想使用 Python HTTP 库来使用带有 API 密钥参数的 URI 读取 Google Cloud 存储对象:

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

此代码将在 GKE 上部署的 Kubernetes pod 中运行。

有没有办法以编程方式检索应用程序默认 API 密钥以附加到 URI?

我想使用 URI 而不是客户端库的原因是因为我需要发出 HTTP Range 请求来检索特定的字节范围。

【问题讨论】:

    标签: python google-kubernetes-engine


    【解决方案1】:

    您没有将官方 Python 客户端库 (https://googlecloudplatform.github.io/google-cloud-python/) 与 Google 云服务帐户(一个 .json 密钥文件)一起使用是否有原因?理想情况下,您不需要自己准备和使用凭据进行 HTTP 调用,这就是客户端库的用途。

    https://cloud.google.com/container-engine/docs/tutorials/authenticating-to-cloud-platform 有一个教程,展示了如何创建凭证、导入 Kubernetes 并在 Pod 中使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-13
      • 2011-07-03
      • 2015-02-03
      • 1970-01-01
      • 2010-09-14
      • 2023-01-24
      • 1970-01-01
      • 2021-12-07
      相关资源
      最近更新 更多