从configmap组成env vars [英] Compose env vars in from configmap

查看:122
本文介绍了从configmap组成env vars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆