【问题标题】:Mount Google storage bucket in Google container在 Google 容器中挂载 Google 存储桶
【发布时间】:2016-06-28 06:27:31
【问题描述】:

我想使用 gcafuse 或任何其他工具/其他规定在 Google Container Engine 中安装 Google 存储桶。容器在谷歌容器引擎下运行所以,我们需要使用yaml文件在里面定义一些参数。

如果有任何东西可以在 .yaml 文件中使用 privileged 和 sys_admin 或其中的任何其他必需参数来构建新的复制控制器/服务。

【问题讨论】:

  • 这个上游issue 似乎相关。似乎还不支持用例,但我可能是错的。在那里问问题可能会从那些专家那里得到答案:)
  • 我已经在 docker 容器镜像中安装了 gcsfuse 并使用 privileged=true 参数挂载它仍然无法将它挂载到容器中。需要更多的投入。 apiVersion:v1 种类:ReplicationController 元数据:名称:apache 规格:副本:1 模板:元数据:标签:app:apache 规格:容器:-名称:apachehttps 图像:httpd:v1 securityContext:功能:{} privileged:true 命令:[ "gcsfuse --key-file=/usr/local/Test.json test1-clod-storage /mnt"] 端口:- containerPort:443 - containerPort:80
  • Nitin,就像 chao 提到的 GCSFuse 目前没有 Kubernetes 卷插件(因为 k8s 中还没有 FUSE FS 支持)。要将 GCS 安装在容器中,您必须使用 gcsfuse 手动设置它,您似乎正在这样做。您在容器日志中看到了哪些错误?
  • 现在我很擅长在 pod 中手动安装存储桶。无论如何在容器/pod启动时挂载存储桶,将“mount /mnt”传递给一些脚本或任何东西。 fstab 在 pod 启动时不起作用。在 fstab 中添加参数后需要手动执行“mount /mnt”,我不想手动挂载它。我正在尝试 yaml 文件中的多个选项。命令:["sh","-c","/usr/local/start.sh"] 执行:命令:"/usr/local/start.sh" 命令:["mount /mnt"] - "/usr /local/start.sh"

标签: json yaml kubernetes google-kubernetes-engine


【解决方案1】:

我们可以使用 gcsfuse 或 s3fuse 将 Google Storage 存储桶挂载到 Kubernetes pod/Container 中。在开始在容器上安装 fuse 之前,使用 SYS_ADMIN 权限运行容器,如下所示。

$ docker run -it --cap-add SYS_ADMIN --name dev --device /dev/fuse ContainerID/Name /bin/bash

  1. 在 pod/Container 映像中安装 gcsfuse 或 s3fuse。
  2. 创建 shell 脚本并在其中添加 mount 命令。
  3. 在 YAML 文件中添加特权参数以授予 pod/Container 管理员权限。 示例如下。

      securityContext:
         capabilities: {}
         privileged: true
    
  4. 在 YAML 文件中添加 Postlife cycle hook 参数以在 pod/Container 的 postStart 后挂载 bucket。 示例如下。

      lifecycle:
        postStart:
         exec:
            command:
              - "sh"
              - "/usr/local/gcsfusemount.sh"
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-21
    • 2019-01-07
    • 2019-01-11
    • 2016-04-17
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 2018-05-08
    相关资源
    最近更新 更多