【问题标题】:Kubernetes on GKE can't mount volumesGKE 上的 Kubernetes 无法挂载卷
【发布时间】:2018-08-03 06:34:25
【问题描述】:

我的集群中有两个节点和 2 个 Pod 在运行 (每个节点上 1 个 pod) 我的持久音量声明低于

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: blockchain-data
  annotations: {
        "volume.beta.kubernetes.io/storage-class": "blockchain-disk"
    }
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ssd
  resources:
    requests:
      storage: 500Gi

mystorageclass

kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
  name: blockchain-disk
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd

我像这样将它安装在我的容器上

spec:
      containers:
        - image: gcr.io/indiesquare-dev/geth-node:v1.8.12
          imagePullPolicy: IfNotPresent
          name: geth-node
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - name: blockchain-data
              mountPath: /root/.ethereum
      volumes:
        - name: blockchain-data
          persistentVolumeClaim: 
            claimName: blockchain-data  

我将副本设置为 2。开始部署时,第一个 pod 正确启动,磁盘正确安装。

但是,第二个 pod 卡在 containtercreating

如果我运行kubectl describe pods

Warning  FailedAttachVolume     18m               attachdetach-controller                       Multi-Attach error for volume "pvc-c56fbb79-954f-11e8-870b-4201ac100003" Volume is already exclusively attached to one node and can't be attached to another

我认为根据此消息,我正在尝试附加已附加到另一个节点的磁盘。

我想要做的是将两个持久卷分别附加到两个 pod。如果 Pod 向上扩展,那么每个 Pod 都应该附加不同的卷。 我该怎么做?

【问题讨论】:

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


    【解决方案1】:

    您不能将 GCE 永久磁盘附加到多个节点。因此,如果您的 pod 登陆不同的节点,您就不能重复使用同一个磁盘。

    您需要类似 ReadOnlyMany 的访问模式,但您有 ReadWriteOnce。

    阅读https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes#access_modes

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      • 2016-12-24
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 2019-08-24
      相关资源
      最近更新 更多