How do I use relative path for a secret mountPath in deployment configuration

2/17/2019

I'm having hard time configuring mountPath as a relative path. Let's say I'm running the deployment from /user/app folder and I want to create secret file under /user/app/secret/secret-volume as follows:

apiVersion: v1
kind: Pod
metadata:
  name: secret-test-pod
spec:
  containers:
    - name: test-container
      image: nginx
      volumeMounts:
          # name must match the volume name below
          - name: secret-volume
            mountPath: secret/secret-volume
  # The secret data is exposed to Containers in the Pod through a Volume.
  volumes:
    - name: secret-volume
      secret:
        secretName: test-secret

For some reason the file secret-volume is created in the root directory /secret/secret-volume.

-- Shiran Amiel
kubernetes
kubernetes-secrets

2 Answers

2/17/2019

The container Mount path needs to be corrected.

-- P Ekambaram
Source: StackOverflow

2/17/2019

It's because you have mountPath: secret/secret-volume change it to mountPath: /user/app/secret/secret-volume

Check documentation here.

-- Vishrant
Source: StackOverflow