kubernetesopenshiftopenshift-3configmap

How can I mount a file with the contents of key/value of a ConfigMap without clearing the folder?


I created a deploymentconfig.yml to deploy an app and a want to mount a file which contents are stored in a ConfigMap. When mounting, the files in the folder that is mounted are replaced. The goal though is to only add/remove/overwrite a specific file in that folder.

spec:
    containers:
          volumeMounts:
          - mountPath: /path/toaSubPath/
            name: somename

Is this possible in this deploymentconfig? If so, how can I do that?


Solution

  • Yes, i am using this to mount default configs. Just use subPath and the file name in subPath. Find below sample it works like a charm

    spec:
      selector:
         matchLabels:
           name: some_name
      template:
        spec:
          containers:
          - args:
            - bash
            - entrypoint.sh
            image: xyz
            imagePullPolicy: IfNotPresent
            name: some_name
            volumeMounts:
            - mountPath: /full/path/to/be/mounted/default.json
              name: config
              subPath: default.json
          volumes:
          - configMap:
              defaultMode: 420
              name: config