<p>I have noticed that when I create and mount a config map that contains some text files, the container will see those files as symlinks to <code>../data/myfile.txt</code> .</p>

<p>For example, if my config map is named tc-configs and contains 2 xml files named stripe1.xml and stripe2.xml, if I mount this config map to /configs in my container, I will have, in my container :</p>

<pre><code>bash-4.4# ls -al /configs/
total 12
drwxrwxrwx    3 root     root          4096 Jun  4 14:47 .
drwxr-xr-x    1 root     root          4096 Jun  4 14:47 ..
drwxr-xr-x    2 root     root          4096 Jun  4 14:47 ..2018_06_04_14_47_03.291041453
lrwxrwxrwx    1 root     root            31 Jun  4 14:47 ..data -&gt; ..2018_06_04_14_47_03.291041453
lrwxrwxrwx    1 root     root            18 Jun  4 14:47 stripe1.xml -&gt; ..data/stripe1.xml
lrwxrwxrwx    1 root     root            18 Jun  4 14:47 stripe2.xml -&gt; ..data/stripe2.xml
</code></pre>

<p>I guess Kubernetes requires those symlinks and ../data and ..timestamp/ folders, but I know some applications that can fail to startup if they see non expected files or folders</p>

<p>Is there a way to tell Kubernetes not to generate all those symlinks and directly mount the files ?</p>

<p>I think this solution is satisfactory : specifying exact file path in mountPath, will get rid of the symlinks to <code>..data and  ..2018_06_04_19_31_41.860238952</code></p>

<p>So if I apply such a manifest : </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: my-lamp-site
spec:
    containers:
    - name: php
      image: php:7.0-apache
      volumeMounts:
      - mountPath: /var/www/html/users.xml
        name: site-data
        subPath: users.xml
    volumes:
    - name: site-data
      configMap:
        name: users

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: users
data:
  users.xml: |
      &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
      &lt;users&gt;
      &lt;/users&gt;
</code></pre>

<p>Apparently, I'm making use of <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath" rel="noreferrer">subpath</a> explicitly, and they're not part of the "auto update magic" from ConfigMaps, I won't see any more symlinks : </p>

<pre><code>$ kubectl exec  my-lamp-site -c php -- ls -al /var/www/html
total 12
drwxr-xr-x 1 www-data www-data 4096 Jun  4 19:18 .
drwxr-xr-x 1 root     root     4096 Jun  4 17:58 ..
-rw-r--r-- 1 root     root       73 Jun  4 19:18 users.xml
</code></pre>

<p>Be careful to not forget <code>subPath</code>, otherwise users.xml will be a directory !</p>

<p>Back to my initial manifest :</p>

<pre><code>spec:
    containers:
    - name: php
      image: php:7.0-apache
      volumeMounts:
      - mountPath: /var/www/html
        name: site-data
    volumes:
    - name: site-data
      configMap:
        name: users
</code></pre>

<p>I'll see those symlinks coming back :</p>

<pre><code>$ kubectl exec  my-lamp-site -c php -- ls -al /var/www/html
total 12
drwxrwxrwx 3 root root 4096 Jun  4 19:31 .
drwxr-xr-x 3 root root 4096 Jun  4 17:58 ..
drwxr-xr-x 2 root root 4096 Jun  4 19:31 ..2018_06_04_19_31_41.860238952
lrwxrwxrwx 1 root root   31 Jun  4 19:31 ..data -&gt; ..2018_06_04_19_31_41.860238952
lrwxrwxrwx 1 root root   16 Jun  4 19:31 users.xml -&gt; ..data/users.xml
</code></pre>

<p><strong>Many thanks to <a href="https://stackoverflow.com/users/46842/psycotica0">psycotica0</a> on <a href="https://k8scanada.slack.com/" rel="noreferrer">K8s Canada slack</a> for putting me on the right track with <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath" rel="noreferrer">subpath</a> (they are quickly mentioned in <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume" rel="noreferrer">configmap documentation</a>)</strong></p>
