【问题标题】:How can I map a docker volume to a google compute engine persistent disk如何将 docker 卷映射到谷歌计算引擎永久磁盘
【发布时间】:2016-09-08 19:03:47
【问题描述】:

我已经完成了在 google 计算引擎中创建永久磁盘并将其附加到正在运行的 VM 实例的步骤。我还使用 VOLUME 指令创建了一个 docker 映像。它在本地运行良好,在 docker run 命令中,我可以通过 -v 选项将主机目录挂载为卷。我以为在 kubectl 中会有类似的命令,但我没有看到。如何将我的永久磁盘挂载为 docker 卷?

【问题讨论】:

    标签: docker google-compute-engine kubernetes


    【解决方案1】:

    在您的 pod 规范中,您可以指定 Kubernetes gcePersistentDisk 卷(spec.volumes 字段)以及将该卷挂载到容器中的位置(spec.containers.volumeMounts 字段)。这是一个例子:

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-pd
    spec:
      containers:
      - image: gcr.io/google_containers/test-webserver
        name: test-container
        volumeMounts:
        - mountPath: /test-pd
          name: test-volume
      volumes:
      - name: test-volume
        # This GCE PD must already exist.
        gcePersistentDisk:
          pdName: my-data-disk
          fsType: ext4
    

    阅读有关 Kubernetes 卷的更多信息:http://kubernetes.io/docs/user-guide/volumes

    【讨论】:

    • 谢谢!理解 docker/kubernetes/google cloud 是如何协同工作的有点令人困惑。
    猜你喜欢
    • 2014-10-17
    • 2014-03-11
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 2023-03-16
    • 2021-05-30
    • 2019-02-18
    相关资源
    最近更新 更多