title: Volume mounted configmap, by label selector
body: <p>I'm looking for a way to mount configs based on label selector.</p>
  
  <p>I will have new configmap's created over time, which I will label with "intendeedtarget"="MainApp".
  The configs are created from json file, with filename as key.</p>
  
  <p>E.g. a yml something like this (but working):</p>
  
  <pre><code>    volumeMounts:
        - name: appconfigs
          mountPath: /appconfigs
    volumes:
    - name: appconfigs
      configMap:
        selector:
          matchLabels:
            intendeedtarget: MainApp
  </code></pre>
  
  <p>That is new configs will be auto mounted in the running pods for the "MainApp" over time.</p>
  
  <p>I have already gotten it to mount individual configs as files in the running pods with:</p>
  
  <pre><code>containers:
        - name: {{Name}}
          image: {{Image}}
          ports:
          - containerPort: 80
          volumeMounts:
            - name: appconfigs
              mountPath: /appconfigs
        volumes:
        - name: appconfigs
          configMap:
            name: {{ConfigName}}
  </code></pre>
  
  <p>This mounts the json applied to the configmap, as a separate file in the /appconfigs folder.</p>
  
  <p>My goal now is to mount all configmaps with the label "intendeedtarget" = "MainApp" in /appconfigs.</p>
  
  <p>Any suggestions?</p>
  
  <p>A bonus question, does anyone know how to label a configmap as one command, i.e. when creating the configmap?</p>
  
  <p>BR</p>