<p>I have multiple configuration files in two directories. For example, </p>

<ul>
<li>conf.d/parentconf1.conf</li>
<li>con.d/node1/child1.conf</li>
<li>conf.d/node2/child2.conf</li>
</ul>

<p>I need to mount these configuration files in the same directory structure to kubernetes pod using <code>ConfigMap</code>.  </p>

<p>Tried using the</p>

<pre><code>kubectl create configmap --from-file=./conf.d --from-file=./conf.d/node1/child1.conf --from-file=./conf.d/node2/child2.conf. 
</code></pre>

<p>Config map created, as expected, cannot express the nested directory structure.  </p>

<p>Is it possible to create ConfigMap recursively from folders and still retain the folder structure in the name of the key entry for the ConfigMap - since the intention is to mount these ConfigMaps into pods?</p>

nashter
<p>Unfortunately, reflecting directory structure in configmap is not supported currently. Workaround is to express directory hierarchy like this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
   name: testconfig
data:
  file1: |
    This is file1
  file2: |
    This is file2 in subdir directory
---
apiVersion: v1
kind: Pod
metadata:
  name: testpod
spec:
  restartPolicy: Never
  containers:
    - name: test-container
      image: gcr.io/google_containers/busybox
      command: [ "/bin/sh","-c", "sleep 1000" ]
      volumeMounts:
      - name: config-volume
        mountPath: /etc/config
  volumes:
    - name: config-volume
      configMap:
        name: testconfig
        items:
        - key: file2
          path: subdir/file2
        - key: file1
          path: file1
</code></pre>
