title: fabric8 API: How do I use a Kubernetes ConfigMap with subPath?
body: <p><strong>Summary</strong>: Is there an example of using an already in existence <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap" rel="nofollow noreferrer">ConfigMap</a> with a <code>subPath</code> option using the Fabric8 APIs? By <code>subPath</code> I mean the K8s configuration (normally expressed in YAML) to inject a single file into a container.</p>
  
  <p><strong>Details</strong>:</p>
  
  <p>I'm attempting to extend the <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="nofollow noreferrer">Jenkins Kubernetes Plugin</a> because we need it to support the K8s  ConfigMap's <code>subPath</code> facility in order to make a file accessible under /etc without then masking the whole of /etc. That plugin uses Fabric8's API in its <a href="https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume.java" rel="nofollow noreferrer">ConfigMapVolume.java</a> file.</p>
  
  <p>What I'm having trouble with are examples demonstrating using K8s ConfigMap with a <code>subPath</code>. Or even finding confirmation that this is supported at all. Any hints to examples or documentation I have missed will be much appreciated.</p>
  
  <p>For reference, an example YAML deployment file that uses <code>subPath</code> is shown below and it references a config map called "resolver-config":</p>
  
  <pre><code>apiVersion: v1
  kind: Pod
  metadata:
    name: test
    namespace: default
  spec:
    containers:
    - name: nginx
      image: nginx
      volumeMounts:
      - name: config-volume
        mountPath: /etc/resolv.conf
        subPath: resolv.conf
    volumes:
      - name: config-volume
        configMap:
          name: resolver-config
  </code></pre>