【发布时间】:2018-11-02 13:43:18
【问题描述】:
我正在开发一个使用 python 客户端库与谷歌云存储通信的 Flask 应用程序。目前,在本地开发中,我使用服务帐户来验证应用程序并进行交互。
我计划构建应用程序的 docker 映像并将其部署在 kubernetes 集群上。我担心的是,我应该如何提供 Google 凭据?
我可能错了,当我在虚拟机上运行这个 python 文件时,它能够创建一个新的存储桶,而不需要凭据或服务帐户。
# Imports the Google Cloud client library
from google.cloud import storage
# Instantiates a client
storage_client = storage.Client()
# The name for the new bucket
bucket_name = 'my-new-bucket'
# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)
print('Bucket {} created.'.format(bucket.name))
如果我将相同的代码 dockerize 到烧瓶应用程序中并将其部署在集群上,它是否仍会使用默认的 google 凭据? 我想知道在 Kubernetes 集群上执行此操作的最佳实践。
【问题讨论】:
标签: docker kubernetes google-cloud-platform google-cloud-storage