We are using k8s as deployment environment, in current spring boot projects we are mounting k8s config maps into container. And start jar with mounted application.yml file. spring out of box support merging projects default application.yml and mounted config/application.yml. In case of spring boot native project we need mechanism to load configmap from k8s to spring boot native container to override default application.yml parameters. Is it possible ?
Asked
Active
Viewed 47 times
0
-
Maybe I don't understand fully, but is it need for you? `prop=${EXTERNAL_ENV_VALUE:defaultValueIfExternalNotExist}` – Numichi May 25 '23 at 11:19
-
partially - yes. but our projects has more than 100 configurable parameters, so separate env for each parameter not convinent. we put all properties file in k8s configmap and mount it to container – Maciavelli May 25 '23 at 11:25
-
1Have you confirmed that external config in a location like `config/application.yml` doesn't work for you in a native executable? It should work the same as in the JVM. Be aware that if the external configuration is enabling features that aren't enabled by default then the app may not work as expected, since code paths that are not exercised at build time will be excluded from the native executable. Any code path that you may want to use at runtime must be known at build time. – Scott Frederick May 26 '23 at 23:02
1 Answers
0
thanks @Scott Frederick turned out that config picked up and works in same way like with jar file. Enough to place application.yml in config folder. But also I noticed that in case of native image config not merged, it replaced config from src/main/resources. So I added additional parameter additional-location in DockerFile
ENTRYPOINT ["/app/info", "--spring.config.additional-location=/app/config/application.yml"]

Maciavelli
- 101
- 1
- 14