<p>I have a Spring boot application, that now I generated a helm chart for it. I am using the ConfigMap from k8s to create this application properties. But When I inspect the pod I see the error below:</p>
<blockquote>
<p>2021-05-31 09:39:31.815  WARN 1 --- [ost-startStop-1]
o.s.b.a.orm.jpa.DatabaseLookup           : Unable to determine jdbc
url from datasource</p>
<p>org.springframework.jdbc.support.MetaDataAccessException: Could not
get Connection for extracting meta-data; nested exception is
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to
obtain JDBC Connection; nested exception is
org.postgresql.util.PSQLException: The connection attempt failed.</p>
</blockquote>
<p>I wrote the application properties as a ConfigMap:</p>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: myconfigmap
data:
  application.properties: |-
    server.port = 8080
    spring.datasource.url={{ .Values.database.url }}
    spring.datasource.username={{ .Values.database.username }}
    spring.datasource.password={{ .Values.database.password }}
</code></pre>
<p>In deployment.yaml I call this using it:</p>
<pre><code>      envFrom:
        - configMapRef:
            name: myconfigmap
</code></pre>
<p>I overwrite the .Values.database... using the keyvault from azure. How is the best way to make this file available on my k8s cluster?</p>
<p>I have the variables overwritten with this command:</p>
<blockquote>
<p>helm upgrade --namespace namescpace --install --set
&quot;database.url=database_url,database.username=username,database.password=password&quot;
name_application chartname</p>
</blockquote>
<p>main class:</p>
<pre><code>@SpringBootApplication
@Configuration
@EnableScheduling
</code></pre>
<p>public class Application extends SpringBootServletInitializer {</p>
<pre><code>/**
 * Main method.
 *
 * @param args
 *            args passed to the Spring Boot App. Can be used to set the
 *            active profile.
 */
public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}

/**
 * Configure method for enabling deployment in external tomcat.
 *
 * {@inheritDoc}
 */
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}
</code></pre>
<p>}</p>

<p>You can't inject files as env-var. Only simple key=value entries.</p>
<p>If you want to keep your configMap as-is you should instead mount it as a volume inside your container.</p>
<pre><code>          volumeMounts:
          - name: application-config 
            mountPath: &quot;/config&quot; 
            readOnly: true
      volumes:
      - name: application-config
        configMap:
          name: myconfigmap
          items:
          - key: application.properties 
            path: application.properties
</code></pre>
<p>Application.properties will now be dropped under /config directory.</p>
<p>Spring will load the mounted file at startup following the documentation : <a href="https://docs.spring.io/spring-boot/docs/2.1.8.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/2.1.8.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files</a></p>
