从configmap组成env vars [英] Compose env vars in from configmap
问题描述
我想在registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
图像的顶部的Wildfly Swarm应用程序构建中设置日志记录级别.配置应用程序的方法是通过env var JAVA_OPTIONS
,因此我想使用
I'd like to set logging level in my Wildfly Swarm app build on top of registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
image. The way to configure the app is through env var JAVA_OPTIONS
, therefore I'd like to use
env:
- name: LOG_LEVEL
valueFrom:
configMapKeyRef:
name: my.configmap
key: log.level
- name: JAVA_OPTIONS
value: -Dswarm.logging=$LOG_LEVEL
遗憾的是(但并不令我感到意外),这不起作用,LOG_LEVEL
无法解决.
Regrettably (but not really to my surprise) this doesn't work, the LOG_LEVEL
is not resolved.
是否可以通过配置映射来构成环境变量,还是必须修改映像以直接使用环境变量?
Is there a way to compose env vars from config map or do I have to modify the image to consume the env vars directly?
推荐答案
您可以使用以下语法引用以前定义的环境变量:
You can reference previously defined environment variables using the following syntax:
env:
- name: LOG_LEVEL
valueFrom:
configMapKeyRef:
name: my.configmap
key: log.level
- name: JAVA_OPTIONS
value: -Dswarm.logging=$(LOG_LEVEL)
不确定在启动时这是否适用于Java选项,但是,我通常已经编辑了映像并调用了entrypoint.sh文件,该文件中存在一些逻辑,但是我猜值得尝试.
Not sure that this will work for java options on startup however, I have usually edited the image and called an entrypoint.sh file where some logic would exist but its worth a try I guess.
这篇关于从configmap组成env vars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!