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 章 配置 Camel K 集成
Camel K 集成生命周期有两个配置阶段:
- 构建时间 - 当 Camel Quarkus 构建 Camel K 集成时,它会消耗构建属性。
- Runtime - 当 Camel K 集成运行时,集成使用运行时属性或来自本地文件、OpenShift ConfigMap 或 Secret 的配置信息。
您使用以下选项以及 kamel run
命令提供配置信息:
-
对于构建时间配置,请使用
--build-property
选项,如 Specifying build-time 配置属性中所述 -
对于运行时配置,请使用
--property
、--config
或--resource
选项,如 指定运行时配置选项所述
例如,您可以使用构建时和运行时选项在 Camel K 中快速配置数据源,如链接中所示: Connect Camel K with database sample configuration。
4.1. 指定构建时配置属性
您可能需要向 Camel Quarkus 运行时提供属性值,以便它能够构建 Camel K 集成。有关构建期间工作的 Quarkus 配置的更多信息,请参阅 Quarkus 构建配置文档。您可以直接在命令行中指定构建属性,也可以通过引用属性文件直接指定。如果在这两个位置都定义了属性,则直接在命令行中指定的值优先于属性文件中的值。
前提条件
- 您必须有权访问安装 Camel K Operator 和 OpenShift Serverless Operator 的 OpenShift 集群:
- 安装 Camel K
- 从 OperatorHub 安装 OpenShift Serverless
- 您知道您要应用到 Camel K 集成的 Camel Quarkus 配置选项。
流程
使用 Camel K
kamel run
命令指定--build-property
选项:kamel run --build-property <quarkus-property>=<property-value> <camel-k-integration>
例如,以下 Camel K 集成(名为
my-simple-timer.yaml
)使用quarkus.application.name
配置选项:- from: uri: "timer:tick" steps: - set-body: constant: "{{quarkus.application.name}}" - to: "log:info"
要覆盖默认应用程序名称,请在运行集成时为
quarkus.application.name
属性的值。例如,要将名称从
my-simple-timer
更改为my-favorite-app
:kamel run --build-property quarkus.application.name=my-favorite-app my-simple-timer.yaml
要提供多个构建时属性,请在
kamel run
命令中添加额外的--build-property
选项:kamel run --build-property <quarkus-property1>=<property-value1> -build-property=<quarkus-property2>=<property-value12> <camel-k-integration>
另外,如果您需要指定多个属性,可以使用
--build-property file
选项指定属性文件:kamel run --build-property file:<property-filename> <camel-k-integration>
例如,以下属性文件(名为
quarkus.properties
)定义了两个 Quarkus 属性:quarkus.application.name = my-favorite-app quarkus.banner.enabled = true
quarkus.banner.enabled
属性指定在集成启动时显示 Quarkus 横幅。使用 Camel K kamel run 命令指定
quarkus.properties
文件:kamel run --build-property file:quarkus.properties my-simple-timer.yaml
Quarkus 解析 属性文件,并使用属性值配置 Camel K 集成。
其他资源
有关 Camel K 集成运行时的 Camel Quarkus 的详情,请参考 Quarkus Trait。