3.5. Camel K インテグレーションの実行
kamel run コマンドを使用すると、コマンドラインから OpenShift クラスターのクラウドで Camel K インテグレーションを実行できます。
前提条件
- 「Camel K 開発環境の設定」
- Java、XML、または YAML DSL で記述された Camel インテグレーションが作成済みである必要があります。
手順
以下の例のように、
ocクライアントツールを使用して OpenShift クラスターにログインします。oc login --token=my-token --server=https://my-cluster.example.com:6443`Camel K オペレーターがインストールされているプロジェクトを開きます。次に例を示します。
oc project my-camel-k-project以下の例のように、Camel K Operator が稼働していることを確認します。
oc get pod以下のような出力が返されます。
NAME READY STATUS RESTARTS AGE camel-k-operator-86b8d94b4-pk7d6 1/1 Running 0 6m28skamel runコマンドを入力し、OpenShift のクラウドでインテグレーションを実行します。以下に例を示します。Java の例
kamel run HelloCamelK.java以下を返します。
integration "hello-camel-k" createdXML の例
kamel run hello-camel-k.xml以下を返します。
integration "hello-camel-k" createdYAML の例
kamel run hello.camelk.yaml以下を返します。
integration "hello" createdkamel getと入力して、統合のステータスを確認します。NAME PHASE KIT hello Building Kit kit-bq666mjej725sk8sn12gインテグレーションが初めて実行されると、Camel K はコンテナーイメージのインテグレーションキットをビルドします。インテグレーションキットは、必要なすべての Camel モジュールをダウンロードし、イメージクラスパスに追加します。
kamel getを再度入力して、インテグレーションが稼働していることを確認します。NAME PHASE KIT hello Running kit-bq666mjej725sk8sn12gkamel logコマンドを入力して、ログをstdoutに出力します。以下に例を示します。
kamel log hello以下のような出力が返されます。
[1] 2020-04-11 14:26:43.449 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.PropertiesFunctionsConfigurer@5223e5ee executed in phase Starting [1] 2020-04-11 14:26:43.457 INFO [main] RuntimeSupport - Looking up loader for language: yaml [1] 2020-04-11 14:26:43.655 INFO [main] RuntimeSupport - Found loader org.apache.camel.k.loader.yaml.YamlSourceLoader@1224144a for language yaml from service definition [1] 2020-04-11 14:26:43.658 INFO [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/i-source-000/hello.camelk.yaml?language=yaml [1] 2020-04-11 14:26:43.658 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesConfigurer@36c88a32 executed in phase ConfigureRoutes [1] 2020-04-11 14:26:43.661 INFO [main] BaseMainSupport - Using properties from: file:/etc/camel/conf/application.properties [1] 2020-04-11 14:26:43.878 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextConfigurer@65466a6a executed in phase ConfigureContext [1] 2020-04-11 14:26:43.879 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) is starting [1] 2020-04-11 14:26:43.880 INFO [main] DefaultManagementStrategy - JMX is disabled [1] 2020-04-11 14:26:44.147 INFO [main] DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html [1] 2020-04-11 14:26:44.157 INFO [main] DefaultCamelContext - Route: route1 started and consuming from: timer://yaml?period=1s [1] 2020-04-11 14:26:44.161 INFO [main] DefaultCamelContext - Total 1 routes, of which 1 are started [1] 2020-04-11 14:26:44.162 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in 0.283 seconds [1] 2020-04-11 14:26:44.163 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@1c93084c executed in phase Started [1] 2020-04-11 14:26:45.183 INFO [Camel (camel-k) thread #1 - timer://yaml] info - 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 インテグレーションの管理」 も参照してください。