将一个文件从ConfigMap挂载到emptyDir挂载点

时间:2018-04-20 09:34:33

标签: kubernetes openshift

我有以下mounPaths:

volumeMounts:
        - mountPath: /var/opt/gitlab/gitaly
          name: gitaly
        - mountPath: /var/opt/gitlab/git-data
          name: git-data
          readOnly: true
        - mountPath: /var/opt/gitlab/git-data2
          name: git-data2
          readOnly: true
        - mountPath: /var/opt/gitlab/gitaly/
          name: config
          subPath: config.toml

第一个mount对应一个emptyDir。我想将configMap中的一个文件(" config")挂载到同一个mountPath中。

这甚至可能吗?之前的配置抛出:

 Error: Error response from daemon: Duplicate mount point '/var/opt/gitlab/gitaly'

2 个答案:

答案 0 :(得分:2)

好的,这里有解决方案,因为我认为其他人可能会遇到同样的问题:

为了从另一个mount的同一路径上只安装configMap中的一个文件:

- mountPath: /var/opt/gitlab/gitaly/config.toml
          name: config
          subPath: config.toml

答案 1 :(得分:0)

emptyDir mount的任何特殊原因?解决方案是在Dockerfile中创建/ var / opt / gitlab,例如:RUN mkdir -p /var/opt/gitlab/并且只使用configMap挂载。