<p>We have a spring MVC application deployed using tomcat image in AKS.
How  to  get values from Secrets mounted as volumes?</p>
<p>Most of the examples points to spring boot only</p>
<p>I am mounting values from secret store</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: nginx
  namespace: default
  labels:
    aadpodidbinding: pod-mi
spec:
  containers:
    - name: nginx
      image: nginx
      volumeMounts:
        - name: foo
          mountPath: &quot;/mnt/secrets&quot;
          readOnly: true
  volumes:
    - name: foo
      csi:
        driver: secrets-store.csi.k8s.io
        readOnly: true
        volumeAttributes:
          secretProviderClass: spc.
</code></pre>
<p>can see the secrets get mounted correctly:</p>
<pre><code>kubectl -n default exec -it nginx -- bash
root@nginx:/# ls /mnt/secrets
service-one-secret
service-two-secret
</code></pre>
<p>Cat service-one-secret doesn't return anything</p>
<p>Can any one suggest a way to read its values from spring mvc application?</p>

Ast
<p>When you mount the secret as a volume to the container, then it would show the data of the secret in that path. For example, you create a secret with the command:</p>
<pre><code>kubectl create secret generic basic-secret \
  --from-literal=username=&quot;jsmith&quot; \
  --from-literal=password=&quot;mysupersecurepassword&quot;
</code></pre>
<p>Then you mount the secret as a volume:</p>
<pre><code>...
spec:
  volumes:
  - name: vol-secret
    secret:
      secretName: my-secret
  containers:
  ...
    volumeMounts:
    - name: vol-secret
      mountPath: /etc/app/secrets
</code></pre>
<p>Then you can see the files named <code>username</code> and <code>password</code> in the path <code>/etc/app/secrets</code>, and the value looks like this:</p>
<pre><code>/ # ls /etc/app/secrets
password  user
/ # cat /etc/app/secrets/password
mysupersecurepassword
/ # cat /etc/app/secrets/username
jsmith
</code></pre>
