Google Kubernetes Engine中“无法为pod安装卷”“超时已过期等待......”的原因是什么?

问题描述 投票:0回答:1

我正在为Google Kubernetes Engine部署3个pod。其中两个pod将ReadOnlyMany绑定共享到预先存在的持久卷,映射到gcePersistentDisk。其中一个豆荚开始了。另一个没有,并最终超时错误“Unable to mount volumes for pod

kubectl describe pvkubectl describe pvc下没有显示错误。 kubectl describe pvc显示每个持久卷声明都绑定到未启动的pod。

相关配置:

kind: PersistentVolume
apiVersion: v1
metadata:
 name: configuration
spec:
  capacity:
    storage: 1G
  accessModes:
    - ReadOnlyMany
  storageClassName: ""
  gcePersistentDisk:
    fsType: ext4
    readOnly: true
    pdName: my-persistent-disk-name
  persistentVolumeReclaimPolicy: Retain
---
kind: PersistentVolume
apiVersion: v1
metadata:
 name: kb
spec:
  capacity:
    storage: 1G
  accessModes:
    - ReadOnlyMany
  storageClassName: ""
  gcePersistentDisk:
    fsType: ext4
    readOnly: true
    pdName: my-persistent-disk-name
  persistentVolumeReclaimPolicy: Retain

---
kind: PersistentVolume
apiVersion: v1
metadata:
 name: content
spec:
  capacity:
    storage: 1G
  accessModes:
    - ReadOnlyMany
  storageClassName: ""
  gcePersistentDisk:
    fsType: ext4
    readOnly: true
    pdName: my-persistent-disk-name
  persistentVolumeReclaimPolicy: Retain
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: config-pvc
spec:
  accessModes:
    - ReadOnlyMany
  volumeName: configuration
  storageClassName: ""
  resources:
    requests:
      storage: 1G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: kb-pvc
spec:
  accessModes:
    - ReadOnlyMany
  volumeName: kb
  storageClassName: ""
  resources:
    requests:
      storage: 1G
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: content-pvc
spec:
  accessModes:
    - ReadOnlyMany
  volumeName: content
  storageClassName: ""
  resources:
    requests:
      storage: 1G
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: worker
spec:
  template:
    spec:
      containers:
        - name: esp
          image: gcr.io/endpoints-release/endpoints-runtime:1.20.0
          args: [ "-http-port", "8080", ... ]
        - name: workers
          image: my-registry/my-image:my-version
          volumeMounts:
            - name: config
              mountPath: /config
              subPath: ./config
              readOnly: true
            - name: kb
              mountPath: /kb
              subPath: ./kb
              readOnly: true
            - name: content
              mountPath: /content
              subPath: ./content
              readOnly: true
      volumes:
         - name: config
           persistentVolumeClaim: 
             claimName: config-pvc
             readOnly: true
         - name: kb
           persistentVolumeClaim: 
             claimName: kb-pvc
             readOnly: true
         - name: content
           persistentVolumeClaim:
             claimName: content-pvc
             readOnly: true
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: another-worker
spec:
  template:
    spec:
      containers:
        - name: another-worker-name
          image: my-registry/my-other-image:my-other-version
         command: ["./run-server.sh", "--path-data", "/config/data/"]
          args: []
          volumeMounts:
            - name: kb
              mountPath: /config
              subPath: ./kb/i2k_context
              readOnly: true
      volumes:        
        - name: kb
          persistentVolumeClaim:
            claimName: kb-pvc
            readOnly: true

上例中名为“worker”的pod应该开始运行。它没有,并最终显示卸载和/或未附加卷的超时错误。

名为“another-worker”的pod启动并按预期运行。

kubernetes google-kubernetes-engine
1个回答
0
投票

看起来GKE不允许多个PersistentVolume对象映射到相同的gcePersistentDisk,即使所有卷和卷声明都是ReadOnlyMany。

我为同一个gcePersistentDisk拥有3个不同PV的原因是为了实现部署的灵活性 - 这三个卷绑定实际上是不同的持久磁盘的能力。

由于我现在没有使用这个功能,我改变了工作舱中的volumesvolumeMounts,使用一个不同的subPathmountPath的PVC,并立即启动了pod。

© www.soinside.com 2019 - 2024. All rights reserved.