fabric8 API: How do I use a Kubernetes ConfigMap with subPath?

12/12/2017

Summary: Is there an example of using an already in existence ConfigMap with a subPath option using the Fabric8 APIs? By subPath I mean the K8s configuration (normally expressed in YAML) to inject a single file into a container.

Details:

I'm attempting to extend the Jenkins Kubernetes Plugin because we need it to support the K8s ConfigMap's subPath 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 ConfigMapVolume.java file.

What I'm having trouble with are examples demonstrating using K8s ConfigMap with a subPath. Or even finding confirmation that this is supported at all. Any hints to examples or documentation I have missed will be much appreciated.

For reference, an example YAML deployment file that uses subPath is shown below and it references a config map called "resolver-config":

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
-- Fred Clausen
fabric8
jenkins
kubernetes

0 Answers