Environment Variables in JAVA_TOOL_OPTIONS #259
Replies: 1 comment 1 reply
-
This is the expected behavior because your application is not started using a shell (so env variables are not shell expanded). Java applications are started directly, not through a shell. This is a requirement for running on smaller base images that don't include a shell.
If K8s is injecting both, can you just have it combine the values? It would know the contents of both values at the time it injects them. Then inject the combined values in Otherwise, you could include a |
Beta Was this translation helpful? Give feedback.
-
I am building a Java/WAR/Tomcat image using:
The image is deployed on a kubernetes cluster, which injects all necessary environmental variables in the pod at deployment time.
I am trying to specify a couple of system properties, whose values need to be picked up from environment variables at startup, like so:
JAVA_TOOL_OPTIONS=-Dexample.sys.prop=${EXAMPLE_SYS_PROP}
Kunernets is injecting both JAVA_TOOL_OPTIONS and EXAMPLE_SYS_PROP correctly from configmap/secret as designed.
But the embedded ${EXAMPLE_SYS_PROP} in JAVA_TOOL_OPTIONS is never resolved to its value and passed as is. As a result my app reads the string '${EXAMPLE_SYS_PROP}' instead of the intended value of the env variable.
Is there any way to accomplish this use case ?
I am guessing this should be a fairly common requirement. Is there a simple solution I am missing?
Thanks in advance for any pointers/help.
Beta Was this translation helpful? Give feedback.
All reactions