Anton Swanevelder
Anton Swanevelder

Reputation: 1155

How to initialize a config file without overwriting mountPath

I need to place a config file default.json in a container mountPath that already have other config files. The way I tried to do this, seems to overwrite the path causing the system not to see the other files in the same directory.

Any ideas how I can do this?

The below code hide the other files from the system.

initContainers:
        - name: install
          image: busybox
          command:
          - wget
          - "-O"
          - "/usr/share/nginx/html/config/default.json"
          - https://s3.eu-central-1.amazonaws.com/.../default.json
          volumeMounts:
            - name: console-config
              mountPath: "/usr/share/nginx/html/config"      
      volumes:
        - name: console-config
          emptyDir: {}

Upvotes: 0

Views: 1450

Answers (1)

Suresh Vishnoi
Suresh Vishnoi

Reputation: 18353

Using subPath field, you can mount the directory or file without overwriting other files, you can find more information here subPath

   initContainers:
        - name: install
          image: busybox
          command:
          - wget
          - "-O"
          - "/usr/share/nginx/html/config/default.json"
          - https://s3.eu-central-1.amazonaws.com/.../default.json
          volumeMounts:
            - name: console-config
              mountPath: "/usr/share/nginx/html/config"
              subPath: config                      
      volumes:
        - name: console-config
          emptyDir: {}

Upvotes: 2

Related Questions