【问题标题】:Kubernetes access Persistance volume mount externallyKubernetes 访问 Persistent volume mount 外部
【发布时间】:2018-07-03 12:53:21
【问题描述】:

我已经在 Google Cloud 中设置了 kubernetes 集群并将卷挂载为 gcePersistentDisk,它在 Pod 中声明并成功挂载。 但我想从外部访问这个卷,以便我可以通过 git/ssh 或手动编写它。由于磁盘已使用并已安装,因此我无法访问它。 如何通过外部写入文件?

【问题讨论】:

    标签: docker kubernetes google-cloud-platform docker-volume


    【解决方案1】:

    gcePersistentDisk是基于网络的磁盘,provisioned volumes只能被GCE使用 同一项目和区域中的实例。

    事实上这种资源支持readWriteOnceReadOnlyMany。 您可以使用 GCE 持久存储在多个 pod 之间以只读方式共享数据 同一个区域。

    回到您的问题:您只能从一个 pod 在此卷上书写。没有其他豆荚可以 将其用作写入存储 - 既不是外部的也不是来自同一个项目。

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: php
      labels:
        app: php
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: php
      template:
        metadata:
          labels:
            app: php
        spec:
          containers:
            - image: php:7.1-apache
              imagePullPolicy: Always
              name: php
              resources:
                requests:
                  cpu: 200m
              ports:
                - containerPort: 80
                  name: php
              volumeMounts:
                - name: php-persistent-storage
                  mountPath: /var/www
          volumes:
            - name: php-persistent-storage
              gcePersistentDisk:
                pdName: php-phantomjs-disk
                fsType: ext4
    

    【讨论】:

      猜你喜欢
      • 2023-01-10
      • 2020-05-31
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多