← 中文资源

简体中文版本

Kubernetes FailedMount: 无法挂载卷

诊断 Kubernetes 的 FailedMount:读取 Pod 事件、检查 configmap 与 secret 是否存在,并解决节点级卷冲突。

阅读英文原文

症状

Pod 卡在 ContainerCreating,并伴随 Warning FailedMount 事件。镜像本身可能没问题,失败发生在准备卷的阶段。

诊断

读取事件并核验被引用的对象:

kubectl describe pod myapp-abc -n prod
kubectl get configmap,secret,pvc -n prod

事件会指出卷名,通常还会给出确切原因。

修复

创建缺失对象并对齐引用:

kubectl create configmap app-config --from-file=config.yaml -n prod
volumes:
  - name: cfg
    configMap:
      name: app-config   # must exist in the same namespace

验证

再次 describe 该 Pod;FailedMount 事件消失,Pod 进入 Running,且 PVC 显示 Bound,确认所有卷都挂载成功。