I am trying to mount a file secret.txt from the secret to location /opt/tomcat/conf/secret.txt. there are other files at the same location e.g. /opt/tomcat/conf/creds.txt that I want to retain.
This is my deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
spec:
replicas: 1
selector:
matchLabels:
app: tomcat
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat-container
image: tomcat:latest
volumeMounts:
- name: secret-volume
mountPath: /opt/tomcat/conf/secret.txt
subPath: secret.txt
volumes:
- name: secret-volume
secret:
secretName: mysecret
items:
- key: secret.txt
path: secret.txt
The secret mysecret was created using the below command.
kubectl create secret generic mysecret --from-file=secret.txt
But this config creates a directory under /opt/tomcat/conf/ with the name secret.txt/ and further places secret.txt file inside it.
Overall result is /opt/tomcat/conf/secret.txt/secret.txt.
I want it to be like /opt/tomcat/conf/secret.txt
Is there any way to achieve this? Any help would be valuable.
Thanks!