Red Hat Camel K is deprecated
Red Hat Camel K is deprecated and the End of Life date for this product is June 30, 2025. For help migrating to the current go-to solution, Red Hat build of Apache Camel, see the Migration Guide.4.2.2.2. 指定 ConfigMap
如果您有一个包含配置值的 OpenShift ConfigMap,且您需要对 ConfigMap 进行材料,使其可用于您的 Camel K 集成,请使用 --config configmap:<configmap-name> 语法。
前提条件
- 设置 Camel K 开发环境
在 OpenShift 集群中存储了一个或多个 ConfigMap 文件。
例如,您可以使用以下命令创建 ConfigMap:
oc create configmap my-cm --from-literal=my-configmap-key="configmap content"
流程
创建引用 ConfigMap 的 Camel K 集成。
例如,以下集成(名为
ConfigConfigmapRoute.java
)在名为my-cm
的 ConfigMap 中引用名为my-configmap-key
的配置值。import org.apache.camel.builder.RouteBuilder; public class ConfigConfigmapRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:configmap") .setBody() .simple("resource:classpath:my-configmap-key") .log("configmap content is: ${body}"); } }
运行集成并使用
--config
选项对 ConfigMap 文件进行整理,使其可用于运行的集成。例如:kamel run --config configmap:my-cm ConfigConfigmapRoute.java --dev
当集成启动时,Camel K operator 会使用 ConfigMap 的内容挂载 OpenShift 卷。
注: 如果您指定集群中还没有可用的 ConfigMap,则集成会等待并在 ConfigMap 可用时启动。