<p>I created kubenertes secret</p>
<pre><code>echo -n 'myusername' &gt; username.txt
echo -n 'pa55word' &gt; password.txt
kubectl create secret generic esb-database-secret-vol --from-file=username.txt --from-file=password.txt
</code></pre>
<p>I created pod manifest as</p>
<pre><code>spec:
  containers:
  - image: data-api-0.0.1.jar
    ports:
    - containerPort: 8080
    name: esb-data-api
    imagePullPolicy: Never
    resources: {}
    volumeMounts:
    - name: esb-secret-vol
      mountPath: &quot;/etc/confidential&quot;
      readOnly: true
  volumes:
  - name: esb-secret-vol
    secret:
      secretName: esb-database-secret-vol
</code></pre>
<p>I verified that secrets now available in pod /etc/confidential folder</p>
<p>How does these values be available in application.properties so that I can get DB connection</p>
<pre><code>spring.datasource.url=jdbc:sqlserver://mycompany.com;databaseName=My_DB
# need to read from /etc/confidential/username.txt
spring.datasource.username=??????
# need to read from /etc/confidential/password.txt  
spring.datasource.password=??????
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
</code></pre>

user3058642
<p>You have several options:</p>
<ol>
<li>Provide the data already in properly written properties files</li>
<li>Use an init container to use the secret data and create properties files using a shell script</li>
</ol>
<p>The first approach would look like</p>
<pre><code>echo 'spring.datasource.username=myusername' &gt;&gt; app.properties
echo 'spring.datasource.password=pa55word' &gt;&gt; app.properties
kubectl create secret generic esb-database-secret-vol --from-file=app.properties
</code></pre>
<p>You would later mount the secret as <code>application.properties</code> in the container.</p>
