<p>I have created ConfigMap from Openshift 4 Windows 10 CLI:</p>
<pre><code>.\oc create configmap my-cacerts --from-file=cacerts
</code></pre>
<p>I can see ConfigMap with name <strong>my-cacerts</strong> and download binary file <strong>cacerts</strong> from it using web interface of Openshift 4</p>
<p>Now I mount it (part of <strong>my-deployment.yaml</strong>)</p>
<pre><code>containers:
  volumeMounts:
    - name: my-cacerts-volume
      mountPath: /etc/my/cacerts
volumes:
  - name: my-cacerts-volume
    config-map: 
      name: my-cacerts
</code></pre>
<p>Unfortunately <em>/etc/my/cacerts</em> is mounted as a empty folder but not as a single binary file.</p>
<p>How can I mount <strong>cacerts</strong> as a file and not as a directory?</p>
<p><strong>Update:</strong></p>
<p>If I issue</p>
<pre><code>.\oc get configmap my-cacerts
</code></pre>
<p>There is following output:</p>
<pre><code>apiVersion: v1
binaryData:
  cacerts: ... big long base64...
kind: ConfigMap
metadata: ...
</code></pre>
<p>If I issue</p>
<pre><code>.\oc describe pod my-pod
</code></pre>
<p>I get</p>
<pre><code>Volumes:
  my-cacerts-volume:
    Type: EmptyDir (a temporary directory that shares a pod's lifetime)
</code></pre>

<p>Your <code>volumes</code> definition is incorrect, <code>config-map</code> <strong>does not exist and is invalid</strong>, but it seems the API is silently falling back to an <code>EmptyDir</code> here, thus leading to an empty directory.</p>
<p>When you create a <code>ConfigMap</code> using the <code>oc</code> command above, the result will be a <code>ConfigMap</code> that looks like this (note that there is one key called &quot;cacerts&quot;):</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: my-cacerts
data:
  cacerts: |
    Hello world!
</code></pre>
<p>In the <code>volumes</code> section, then use <code>configMap:</code> together with <code>subPath</code> as follows to mount a only a single key (&quot;cacerts&quot;) from your <code>ConfigMap</code>:</p>
<pre><code>$ oc edit deployment my-deployment
[..]
    spec:
      containers:
      - image: registry.fedoraproject.org/fedora-minimal:33
        name: fedora-minimal
        volumeMounts:
        - mountPath: /etc/my/cacerts
          name: my-cacerts-volume
          subPath: cacerts
[..]
      volumes:
      - configMap:
          name: my-cacerts
          defaultMode: 420
        name: my-cacerts-volume
</code></pre>
<p>This then results in:</p>
<pre><code>$ oc rsh ...
sh-5.0$ ls -l /etc/my/cacerts
-rw-r--r--. 1 root 1000590000 13 Dec  3 19:11 /etc/my/cacerts
sh-5.0$ cat /etc/my/cacerts
Hello world!
</code></pre>
<p>You can also leave <code>subPath</code> out and set <code>/etc/my/</code> as the destination for the same result, as for each key there will be a file:</p>
<pre><code>[..]
        volumeMounts:
        - mountPath: /etc/my/
          name: my-cacerts-volume
[..]
      volumes:
      - configMap:
          name: my-cacerts
        name: my-cacerts-volume
</code></pre>
<p>For the right syntax, you can also check <a href="https://docs.openshift.com/container-platform/4.6/builds/builds-configmaps.html#builds-configmaps-use-case-consuming-in-volumes_builds-configmaps" rel="nofollow noreferrer">the documentation</a></p>
