Description
Use case
Providing a Helm Chart for a Spring Boot application, typically requires translating input from values.yaml
to application properties.
There are many ways to achieve this, one of the most straightforward ways being using environment variables.
However, there are a few drawbacks with such strategy:
- limitations with case-sensitive properties such as Document logger environment variable restrictions #17958
- helm / kubernetes resources are yaml-based and dynamically translating yaml snippets to environment variables requires some helm templating wizardry
- support for defining property source / document order priority
Converting yaml snippet to json and injecting it in the SPRING_APPLICATION_JSON
almost fits the purpose, but helm's fromYaml
function has limitations such as support for multi-documents (see helm/helm#11647) and SPRING_APPLICATION_JSON
doesnt support much flexibility in terms of document order priority.
The proposal
To improve developer experience when creating helm charts for Spring Boot apps, the proposal is to allow loading via spring.config.import
a full config yaml file encoded in a single environment variable.
Given the following application.yaml (burned in the container image):
logging:
level:
acme.MyClass: ERROR
spring:
config:
import:
- optional:env:HELM_APPLICATION_YAML[.yaml]
When the multi-line environment variable HELM_APPLICATION_YAML
is defined for the container (rendered by helm):
logging:
level:
acme.MyClass: DEBUG
---
acme:
property1: 1
Then, the final configured level for acme.MyClass
should be DEBUG.
Optionally we can support base64-encoded env vars for simplifying creation of multi-line env vars, via something like optional:env:base64:HELM_APPLICATION_YAML[.yaml]
Ps: In the examples I mentioned yaml, but it would support properties files as well via the [.properties] hint
I already have a PoC working code for supporting this and Im willing to contribute if the feature is acceptable.