第 1 章 管理 Camel K 集成

您可以使用 Camel K 命令行或使用开发工具来管理红帽集成 - Camel K 集成。本章解释了如何在命令行中管理 Camel K 集成,并提供解释了如何使用 VS Code 开发工具的其他资源的链接。

1.1. 管理 Camel K 集成

Camel K 提供在命令行上在 OpenShift 集群上管理 Camel K 集成的不同选项。本节展示了使用以下命令的简单示例:

  • kamel get
  • kamel describe
  • kamel log
  • kamel delete

先决条件

流程

  1. 确保 Camel K Operator 在 OpenShift 集群中运行,例如:

    oc get pod
    NAME                               READY   STATUS    RESTARTS   AGE
    camel-k-operator-86b8d94b4-pk7d6   1/1     Running   0          6m28s
  2. 输入 kamel run 命令,以在 OpenShift 的云中运行您的集成。例如:

    kamel run hello.camelk.yaml
    integration "hello" created
  3. 输入 kamel get 命令检查集成的状态:

    kamel get
    NAME   PHASE        KIT
    hello  Building Kit kit-bqatqib5t4kse5vukt40
  4. 输入 kamel describe 命令来打印有关集成的详细信息:

    kamel describe integration hello
    Name:                hello
    Namespace:           myproject
    Creation Timestamp:  Fri, 13 Aug 2021 16:23:21 +0200
    Phase:               Building Kit
    Runtime Version:     1.7.1.fuse-800025-redhat-00001
    Kit:                 myproject/kit-c4ci6mbe9hl5ph5c9sjg
    Image:
    Version:             1.6.6
    Dependencies:
      camel:core
      camel:log
      camel:timer
      mvn:org.apache.camel.k:camel-k-runtime
      mvn:org.apache.camel.quarkus:camel-quarkus-yaml-dsl
    Sources:
      Name                        Language  Compression  Ref  Ref Key
      camel-k-embedded-flow.yaml  yaml      false
    Conditions:
      Type                          Status  Reason                        Message
      IntegrationPlatformAvailable  True    IntegrationPlatformAvailable  myproject/camel-k
      IntegrationKitAvailable       True    IntegrationKitAvailable       kit-c4ci6mbe9hl5ph5c9sjg
      CronJobAvailable              False   CronJobNotAvailableReason     different controller strategy used (deployment)
      DeploymentAvailable           True    DeploymentAvailable           deployment name is hello
      KnativeServiceAvailable       False   KnativeServiceNotAvailable    different controller strategy used (deployment)
      Ready                         True    ReplicaSetReady
  5. 输入 kamel log 命令将日志输出到 stdout

    kamel log hello
    ...
    [1] 2021-08-13 14:37:15,860 INFO [info] (Camel (camel-1) thread #0 - timer://yaml) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from yaml]
    ...
  6. Ctrl-C 终止终端中的日志记录。
  7. 输入 kamel delete 以删除在 OpenShift 上部署的集成:

    kamel delete hello
    Integration hello deleted

其他资源