How do I mount a single file from a secret in Kubernetes?
You can do as bellow:
apiVersion: v1kind: Podmetadata: name: mypodspec: containers: - name: mypod image: redis volumeMounts: - name: foo mountPath: "/etc/foo" readOnly: true volumes: - name: foo secret: secretName: mysecret items: - key: username path: my-group/my-username
Suppose mysecret
contains username
and password
. Above yaml will mount only username
in /etc/foo/my-group/my-username
directory.
For more details check this: Using Secrets as Files from a Pod