3.4. Camel K インテグレーションの実行

kamel run コマンドを使用すると、コマンドラインから OpenShift クラスターのクラウドで Camel K インテグレーションを実行できます。

前提条件

手順

  1. 以下の例のように、oc クライアントツールを使用して OpenShift クラスターにログインします。

    $ oc login --token=my-token --server=https://my-cluster.example.com:6443
  2. 以下の例のように、Camel K Operator が稼働していることを確認します。

    $ oc get pod
    NAME                               READY   STATUS    RESTARTS   AGE
    camel-k-operator-86b8d94b4-pk7d6   1/1     Running   0          6m28s
  3. kamel run コマンドを入力し、OpenShift のクラウドでインテグレーションを実行します。以下に例を示します。

    Java の例

    $ kamel run HelloCamelK.java
    integration "hello-camel-k" created

    YAML の例

    $ kamel run hello.camelk.yaml
    integration "hello" created

  4. kamel get コマンドを入力し、インテグレーションの状態を確認します。

    $ kamel get
    NAME       PHASE           KIT
    hello      Building Kit    myproject/kit-bq666mjej725sk8sn12g

    インテグレーションが初めて実行されると、Camel K はコンテナーイメージのインテグレーションキットをビルドします。インテグレーションキットは、必要なすべての Camel モジュールをダウンロードし、イメージクラスパスに追加します。

  5. kamel get を再度入力して、インテグレーションが稼働していることを確認します。

    $ kamel get
    NAME       PHASE   KIT
    hello      Running myproject/kit-bq666mjej725sk8sn12g
  6. 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.4.0 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]
    ...
  7. Ctrl-C キーを押して、ターミナルでログインを終了します。

関連情報