0

I want to map a file at a certain path in container to a file at a different path in the mounted volume.

For example:

File in Container ---> /some/path/folder/file.config

File in Volume ----> /some/other/path/different/folder/another_file.config

The use case involves fetching config files from a git repo using init containers and adding them to an emptyDir volume.

apiVersion: v1
kind: Pod
metadata:
  name: pod
spec:
  initContainers:
    - name: git-sync
    ...
      volumeMounts:
        - mountPath: some/path/folder
          name: volume
  containers:
    - name: some-container
      image: some-image
      volumeMounts:
        - mountPath: some/path/folder/file.config
          subPath: /some/other/path/different/folder/another_file.config
          name: volume
  volumes:
    - name: kibana-volume
      emptyDir: {}

PS: This has to be done using a volume (not a configmap) as there is a need to continuously sync git repo.

David Maze
  • 94,671
  • 18
  • 109
  • 144
Gurleen Sethi
  • 2,718
  • 4
  • 22
  • 42
  • Did you take a look: https://stackoverflow.com/questions/37317003/restart-pods-when-configmap-updates-in-kubernetes ? – Malgorzata Dec 02 '20 at 17:13
  • @Malgorzata this is completely different from what my question is. – Gurleen Sethi Dec 03 '20 at 17:35
  • Solution I have mentioned assume that always you can write a custom pid1 that notices the confimap has changed and restarts your app. So not necessairly you have to use volume. – Malgorzata Dec 15 '20 at 12:36

0 Answers0