What’s the best way to share/mount one file into a pod?

For example you have a configmap which contain 2 config files:

kubectl create configmap config --from-file <file1> --from-file <file2>

You could use subPath like this to mount single file into existing directory:

---
        volumeMounts:
        - name: "config"
          mountPath: "/<existing folder>/<file1>"
          subPath: "<file1>"
        - name: "config"
          mountPath: "/<existing folder>/<file2>"
          subPath: "<file2>"
      restartPolicy: Always
      volumes:
        - name: "config"
          configMap:
            name: "config"
---

Full example here

Leave a Comment