【问题标题】:Kubernetes PV/PVC not mounting to the correct volumeMounts in the podsKubernetes PV/PVC 未安装到 pod 中的正确 volumeMounts
【发布时间】:2020-06-27 01:53:29
【问题描述】:

我的新部署遇到了一个奇怪的问题,其中卷未正确安装。

例子..

与一个部署相关的三个 NFS 目录有 PV/PVC:

  • NFS/in
  • NFS/输出
  • NFS/配置

在部署中,这些 PVC 挂载到相应的 volumeMounts

  • volumeMounts/in
  • volumeMounts/out
  • volumeMounts/配置

使用我的旧部署,这可以按预期工作。在新部署中,NFS 目录挂载到不正确的挂载点... NFS/in 的内容挂载在 volumeMounts/config 中。 NFS/config 挂载在 volumeMounts/in 中。

这是裸机节点上的普通 Kubernetes。对默认配置的唯一更改是取消 PVC 保护,因为 PVC 未按请求删除:

kubectl patch pvc PVC_NAME -p '{"metadata":{"finalizers": []}}' --type=merge

关于是什么导致目录安装在不正确的volumeMounts中的任何想法?

【问题讨论】:

  • 如果没有看到确切的资源 YAML,可能很难识别。盲目猜测 - 无论如何与选择的存储类类型有关?

标签: kubernetes persistent-volumes persistent-volume-claims


【解决方案1】:

您必须通过部署或 statefulset 设置 ClaimName :

...
apiVersion: apps/v1
kind: StatefulSet
.......
   containers:
      - name: container-name
        image: container-image:container-tag
        volumeMounts:
        - name: claim1
          mountPath: /path/to/directory
   volumes:
      - name: claim1
        persistentVolumeClaim:
          claimName: PVC_NAME
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-13
    • 2017-10-27
    • 1970-01-01
    • 2020-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多