【问题标题】:Using gsutil to copy a file from a GKE container fails with AccessDeniedException: 403 Insufficient Permission使用 gsutil 从 GKE 容器复制文件失败并出现 AccessDeniedException: 403 Insufficient Permission
【发布时间】:2021-03-07 12:56:02
【问题描述】:

我在 Dockerfile 中安装了 gsutil,如下所示:

FROM postgres
RUN apt-get update -y
RUN apt-get install -y curl python && curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:/root/google-cloud-sdk/bin

然后将其作为容器部署在以下 Pod 中:

apiVersion: v1
kind: Pod
metadata:
  name: postgresql-backup
spec:
  containers:
    - name: web
      image: xxx/posgresql-backup:latest
      ports:
        - name: web
          containerPort: 80
          protocol: TCP
      command: ['sh', '-c', 'echo The app is running! && sleep 36000']

请注意,在我的例子中,容器正在默认服务帐户下执行:111111111-compute@developer.gserviceaccount.com

我之前创建了一个名为:posgresql-backup 的存储桶

当我在执行容器中打开终端时:kubectl exec -it xxx -- /bin/bash

如果我运行gsutil ls gs://posgresql-backup,它会返回该存储桶中的文件列表:

gs://posgresql-backup/dump1.sql

但是,当我尝试将文件从容器 cp 到存储桶 gsutil cp myfile.txt gs://posgresql-backup 时:

AccessDeniedException: 403 Insufficient Permission     

在存储桶权限中,我将服务帐户添加为存储管理员和存储对象管理员,但没有任何区别。

我还缺少什么?

【问题讨论】:

    标签: google-cloud-platform google-cloud-storage google-kubernetes-engine gsutil


    【解决方案1】:

    问题在于 GKE 节点的默认节点池配置将 Cloud Storage API 设置为只读,因此我必须对其进行自定义:

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 2018-04-15
      • 2021-09-23
      • 2016-10-25
      • 2014-10-01
      • 2016-09-04
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      相关资源
      最近更新 更多