Mount one file from ConfigMap into the emptyDir mountpoint

4/20/2018

I have the following 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

The first mount corresponds to an emptyDir. I would like to mount just one of the files from a configMap ("config") into the same mountPath.

Is this even possible? The previous configuration throws:

 Error: Error response from daemon: Duplicate mount point '/var/opt/gitlab/gitaly'
-- djuarez
kubernetes
openshift

2 Answers

4/20/2018

Any particular reason of the emptyDir mount? A solution would be to create the /var/opt/gitlab in the Dockerfile, e.g: RUN mkdir -p /var/opt/gitlab/ and only use the configMap mounts.

-- hfskappel
Source: StackOverflow

4/20/2018

Ok, here there is the solution, as I think someone else can have the same problem:

In order to mount only one file from the configMap on the very same path from another mount:

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