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
.
The container Mount path needs to be corrected.
It's because you have mountPath: secret/secret-volume
change it to mountPath: /user/app/secret/secret-volume