mount dot files in home folder of pod blowing away folder

6/7/2019

I am building containers that are designed to build and publish things. So i need to configure the .pypirc, etc files.

I am trying to do it with a configmap. Creating a configmap with each of the dot files is easy enough, my problem is mapping it into the pod.

apiVersion: v1
kind: Pod
metadata:
  generateName: jnlp-
labels:
  name: jnlp
  label: jnlp
spec:
  containers:
    - name: jnlp
      image: '(redacted)/agent/cbuild-okd311-cmake3-py36:0.0.2.7'
      tty: true
      securityContext:
        runAsUser: 1001
        allowPrivilegeEscalation: false
      volumeMounts:
        - name: dotfiles
          mountPath: "/home/jenkins"
  volumes:
    - name: dotfiles
      configMap:
        name: jenkins.user.dotfiles

heres my map (redacted)

apiVersion: v1
data:
  .pypirc: |-
    [distutils]
    index-servers = local
    [local]
    repository: https://(redacted)/api/pypi/pypi 
    username: (redacted)
    password: (redacted)
  .p4config: |-
    P4CLIENT=perf_pan
    P4USER=(redacted)
    P4PASSWD=(redacted)
    P4PORT=p4proxy-pa.(redacted):1666
    P4HOST=(redacted).com%
kind: ConfigMap
metadata:
  name: jenkins.user.dotfiles
  namespace: jenkins

im pretty sure that the mount command is blowing away everything else thats in the /home/jenkins folder. But im trying to come up with a mount that will create a dot file for each entry in my configmap.

Thanks

-- scphantm
kubernetes

1 Answer

6/7/2019

Your suspicion is correct. What you can use to fix that is subPath https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath

But the downside is you do need a volumeMount entry for each of the dotfiles.

-- coderanger
Source: StackOverflow