<p>I have simple Spring boot application which I need to deploy on development and prod different namespaces on a Kubernetes cluster using Helm.</p>

<p>I was thinking about keeping multiple application.properties (application-dev.properties, application-prod.properties) files for each environment and then create configmaps from them through values.yaml files which also will be different for each environment and specified when I execute Helm upgrade.</p>

<p>Now the question is how do I consume values from config.maps as I understand I can either mount the properties file inside container for example /deployment/application.properties</p>

<p>Or expose each property as an environment variable inside container.</p>

<p>But how do I consume them from Java application?</p>

<p>Also at the moment when I create container image it has current application .properties inside /resources/ files embedded and this is what application is using from default so I need to overwrite this behaviour when application is running inside container as opposite to then when its just build and run manually on developer desktop.</p>

<p>Springboot can automatically infer variables from environment variables.  In your application.properties or application.yaml, just use ${MY_ENVIRONMENT_VARIABLE:my-defaultvalue}.<br>
Use helm to populate your configmap.
Use configmap as environment variables into your deployment manifest.</p>

<p>This way you do not need to have multiple application.properties for dev, int ,prod inside your image.  Keeping it intact across deployment.  </p>

<p>And then in your helm chart, you can have multiple values.yaml example values-dev.yaml or values-int.yaml.  you can also dynamically set helm values from command line, overriding the yaml file.</p>

<p>I have a demo app in github <a href="https://github.com/balchua/demo" rel="noreferrer">https://github.com/balchua/demo</a>, which  uses this pattern.</p>
