3.4. 运行 Camel K 集成
您可以使用 kamel run
命令从命令行在 OpenShift 集群上在云中运行 Camel K 集成。
前提条件
- 设置您的 Camel K 开发环境.
- 您必须具有用 Java 或 YAML DSL 编写的 Camel 集成。
流程
使用
oc
客户端工具登录到 OpenShift 集群,例如:$ oc login --token=my-token --server=https://my-cluster.example.com:6443
确保 Camel K Operator 正在运行,例如:
$ oc get pod NAME READY STATUS RESTARTS AGE camel-k-operator-86b8d94b4-pk7d6 1/1 Running 0 6m28s
输入
kamel run
命令,在 OpenShift 上的云中运行您的集成。例如:Java 示例
$ kamel run HelloCamelK.java integration "hello-camel-k" created
YAML 示例
$ kamel run hello.camelk.yaml integration "hello" created
输入
kamel get
命令检查集成状态:$ kamel get NAME PHASE KIT hello Building Kit myproject/kit-bq666mjej725sk8sn12g
当集成首次运行时,Camel K 为容器镜像构建集成套件,这会下载所有必要的 Camel 模块并将其添加到镜像类路径中。
再次输入
kamel get
来验证集成是否正在运行:$ kamel get NAME PHASE KIT hello Running myproject/kit-bq666mjej725sk8sn12g
输入
kamel log
命令,将日志输出到stdout
:$ kamel log hello [1] 2021-08-11 17:58:40,573 INFO [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.7.1.fuse-800025-redhat-00001 [1] 2021-08-11 17:58:40,653 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime [1] 2021-08-11 17:58:40,844 INFO [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='camel-k-embedded-flow', language='yaml', location='file:/etc/camel/sources/camel-k-embedded-flow.yaml', } [1] 2021-08-11 17:58:41,216 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup summary (total:1 started:1) [1] 2021-08-11 17:58:41,217 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Started route1 (timer://yaml) [1] 2021-08-11 17:58:41,217 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 3.10.0.fuse-800010-redhat-00001 (camel-1) started in 136ms (build:0ms init:100ms start:36ms) [1] 2021-08-11 17:58:41,268 INFO [io.quarkus] (main) camel-k-integration 1.6.6 on JVM (powered by Quarkus 1.11.7.Final-redhat-00009) started in 2.064s. [1] 2021-08-11 17:58:41,269 INFO [io.quarkus] (main) Profile prod activated. [1] 2021-08-11 17:58:41,269 INFO [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-k-core, camel-k-runtime, camel-log, camel-support-common, camel-timer, camel-yaml-dsl, cdi] [1] 2021-08-11 17:58:42,423 INFO [info] (Camel (camel-1) thread #0 - timer://yaml) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from yaml] ...
-
按
Ctrl-C
在终端中终止登录。
其他资源
-
如需
kamel run
命令的更多详细信息,请输入kamel run --help
- 有关更快速的部署周转时间,请参阅 在开发模式下运行 Camel K 集成
- 有关运行集成的开发工具详情,请参阅 Red Hat Apache Camel K 的 VS Code 工具
- 另请参阅 管理 Camel K 集成