<p>I want to be able to mount an unknown number of config files in /etc/configs</p>
<p>I have added some files to the configmap using:</p>
<blockquote>
<p>kubectl create configmap etc-configs --from-file=/tmp/etc-config</p>
</blockquote>
<p>The number of files and file names are never going to be known and I would like to recreate the configmap and the folder in the Kubernetes container should be updated after sync interval.</p>
<p>I have tried to mount this but I'm not able to do so, the folder is always empty but I have data in the configmap.</p>
<pre><code>bofh$ kubectl describe configmap etc-configs
Name:         etc-configs
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
file1.conf:
----
{
 ... trunkated ...
}
file2.conf:
----
{
 ... trunkated ...
}
file3.conf:
----
{
 ... trunkated ...
}

Events:  &lt;none&gt;
</code></pre>
<p>I'm using this one in the container volumeMounts:</p>
<pre><code>- name: etc-configs
  mountPath: /etc/configs
</code></pre>
<p>And this is the volumes:</p>
<pre><code>- name: etc-configs
  configMap:
    name: etc-configs
</code></pre>
<p>I can mount individual items but not an entire directory.</p>
<p>Any suggestions about how to solve this?</p>

Johan Ryberg
<p>You can mount the ConfigMap as a special volume into your container.</p>
<p>In this case, the mount folder will show each of the keys as a file in the mount folder and the files will have the map values as content.</p>
<p>From the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#populate-a-volume-with-data-stored-in-a-configmap" rel="noreferrer">Kubernetes documentation</a>:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
...
      volumeMounts:
      - name: config-volume
        mountPath: /etc/config
  volumes:
    - name: config-volume
      configMap:
        # Provide the name of the ConfigMap containing the files you want
        # to add to the container
        name: special-config
</code></pre>
