体积 Mount 失败
错误信息
MountVolume.设置失败 for 体积: path 做不 exist
快速摘要
容器 cannot mount 体积, 通常因为源 path 做不 exist, permissions 是错误, or 体积类型是 misconfigured.
为什么发生
host path specified in hostPath 体积做 不 exist on 节点
PersistentVolume or PersistentVolumeClaim 做不 exist or 是不 边界
Insufficient permissions 到读取 or 编写体积 mount path
体积类型是 不 supported on 节点's 操作系统
最小示例
volumes:
- name: data
hostPath:
path: /data/app # path does not exist on hostvolumes:
- name: data
hostPath:
path: /data/app
type: DirectoryOrCreate # creates if missingbroken code 失败因为 host path 做不 exist. fix uses DirectoryOrCreate 到创建它 automatically.
如何诊断
检查 Pod 事件使用
kubectl 描述 pod <pod-name>验证体积 and mount paths in Pod spec
检查如果 hostPath exists on 节点:
ls /path/到/体积验证 PVC 状态:
kubectl 获取 pvc <pvc-name>
如何修复
创建 missing host directory:
mkdir -p /path/到/体积Fix 体积 name or path in Pod spec 到 match 实际 resource
Ensure PersistentVolumeClaim 是边界之前 deploying Pod
Fix file permissions on host:
chmod 755 /path/到/体积
如何预防
Use PersistentVolumeClaims 相反的 hostPath for production
验证体积 resources exist 之前 deploying Pods
Use init 容器到 prepare 体积 directories