You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes挂载ConfigMap报错“mount through procfd: not a directory”求助

问题分析与解决

报错caused: mount through procfd: not a directory: unknown的核心原因是:使用subPath挂载单个文件时,Kubernetes要求目标文件的父目录必须预先存在于容器镜像中。如果容器启动时/opt/druid/conf/druid/cluster/_common/目录不存在,Kubernetes会尝试将ConfigMap中的文件当作目录挂载,从而触发该错误。

解决办法

方案1:容器启动前创建父目录

修改Deployment的启动命令,先创建目标父目录,再启动应用:

...
spec:
  containers:
  - name: your-container-name
    image: your-image
    command: ["/bin/sh", "-c"]
    args:
      - "mkdir -p /opt/druid/conf/druid/cluster/_common/ && exec /your-original-start-script"
    volumeMounts:
      - mountPath: /opt/druid/conf/druid/cluster/_common/yarn-site.xml
        name: hdfs-volume
        subPath: yarn-site.xml
      - mountPath: /druid/data
        name: data-volume
...
volumes:
  - name: hdfs-volume
    configMap:
      name: hdfs-yarn
      items:
      - key: yarn-site.xml
        path: yarn-site.xml
...

注:将/your-original-start-script替换为容器原本的启动命令/脚本。

方案2:先挂载到临时目录再复制文件

将ConfigMap挂载到临时目录,再通过启动命令将文件复制到目标路径,避免挂载时的父目录依赖:

...
spec:
  containers:
  - name: your-container-name
    image: your-image
    command: ["/bin/sh", "-c"]
    args:
      - "mkdir -p /opt/druid/conf/druid/cluster/_common/ && cp /tmp/configs/yarn-site.xml /opt/druid/conf/druid/cluster/_common/ && exec /your-original-start-script"
    volumeMounts:
      - mountPath: /tmp/configs
        name: hdfs-volume
      - mountPath: /druid/data
        name: data-volume
...
volumes:
  - name: hdfs-volume
    configMap:
      name: hdfs-yarn
...

此方案无需依赖镜像中预先存在的目录,灵活性更强。

可选优化:简化ConfigMap配置

由于你的ConfigMap中key和path同名,items配置可以省略,简化后的volumes部分如下:

volumes:
  - name: hdfs-volume
    configMap:
      name: hdfs-yarn

内容的提问来源于stack exchange,提问作者CSUNNY

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 07:15:32