【问题标题】:Google Cloud Storage upload using autoscalling under load balancer在负载均衡器下使用自动缩放的 Google Cloud Storage 上传
【发布时间】:2020-08-08 20:16:16
【问题描述】:

我从 Compute Engine 实例组将图像上传到 Google Cloud Storage 时遇到问题。

之前我使用的是引擎正常运行的机器 A。 当一台机器B使用机器A的镜像在同一个组实例中启动时,上传不成功,403 unathorized。

即使有一个以json形式导出凭证的脚本如下:

- gcloud auth activate-service-account xxxxxxt@xxxxxxx.iam.gserviceaccount.com
--key-file = / home / username / key.json --project = xxxx-xxxx
- export GOOGLE_APPLICATION_CREDENTIALS = "/ home / username / key.json"

我使用 Python 作为编程语言。

当模板 B 不起作用时,我使用模板 A 再次返回它,它起作用了。

我的更新步骤如下:

更新机器 A 上的配置 -> 使用机器从机器 A 创建映像 名称 B -> 从图像机器 B 创建模板 -> 使用相同 组实例 -> 用引擎 B 模板替换机器 A 模板

【问题讨论】:

  • 你的机器在 GCP 上吗?
  • 是的,我的机器在 gcp 上。
  • 您能否尝试删除 key.json 文件并将服务帐号设置到 Compute Engine 配置中?在 GCP 上,您不需要服务帐号密钥!
  • 你好@guillaumeblaquiere 谢谢你的回答,我可以在制作机器时直接使用身份和api访问机器,现在机器又可以正常运行了。再次感谢。

标签: flask google-cloud-platform google-cloud-storage load-balancing autoscaling


【解决方案1】:

我代表 @guillaumeblaquiere 发布答案,他是该问题的最初解决者:

在 Compute Engine 中,您不需要将凭据作为 json 密钥传递。相反,您应该使用 Compute Engine 服务帐户并为其提供正确的 IAM permisions 以写入您的存储桶

【讨论】:

    猜你喜欢
    • 2016-11-03
    • 2022-10-20
    • 2015-08-25
    • 1970-01-01
    • 2019-05-20
    • 2018-09-20
    • 2017-09-21
    • 2021-12-07
    • 2023-04-05
    相关资源
    最近更新 更多