【问题标题】:What are reasons for "Unable to mount volumes for pod" "timeout expired waiting for ..." in Google Kubernetes Engine?Google Kubernetes Engine 中“无法为 pod 挂载卷”“超时已过期等待...”的原因是什么?
【发布时间】:2019-09-15 08:48:06
【问题描述】:

我正在将 3 个 Pod 部署到 Google Kubernetes Engine。其中两个 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】:

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

    我为相同的gcePersistentDisk 拥有 3 个不同的 PV 的原因是允许部署的灵活性——让这三个卷绑定实际上是不同的永久磁盘的能力。

    由于我目前没有使用该功能,因此我将 worker pod 中的 volumesvolumeMounts 更改为使用具有不同 subPathmountPath 的 PVC 并且 pod 立即启动。

    【讨论】:

      猜你喜欢
      • 2018-06-12
      • 2016-12-24
      • 1970-01-01
      • 2018-07-28
      • 2022-07-14
      • 1970-01-01
      • 2021-07-14
      • 2021-11-22
      • 1970-01-01
      相关资源
      最近更新 更多