開発モードの Camel K インテグレーションは、コマンドラインから OpenShift クラスターで実行できます。開発モードを使用すると、開発段階にてインテグレーションで繰り返しを迅速に行うことができ、コードに関するフィードバックを即座に受け取ることができます。
--dev オプションを指定して kamel run コマンドを実行すると、インテグレーションがクラウドで即座にデプロイされ、ターミナルにインテグレーションログが表示されます。次に、コードを変更でき、変更が自動的かつ即座に OpenShift のリモートインテグレーション Pod に適用されることを確認できます。ターミナルには、クラウドのリモートインテグレーションの再デプロイメントすべてが自動的に表示されます。
注記
開発モードで Camel K によって生成されたアーティファクトは、実稼働環境で実行するアーティファクトと同じです。開発モードの目的は、より迅速な開発を行うことです。
Copy to ClipboardCopied!Toggle word wrapToggle overflow
以下の例のように、Camel K Operator が稼働していることを確認します。
oc get pod
NAME READY STATUS RESTARTS AGE
camel-k-operator-86b8d94b4-pk7d6 1/1 Running 0 6m28s
$ oc get pod
NAME READY STATUS RESTARTS AGE
camel-k-operator-86b8d94b4-pk7d6 1/1 Running 0 6m28s
Copy to ClipboardCopied!Toggle word wrapToggle overflow
kamel run コマンドと --dev を入力し、クラウドの OpenShift にて開発モードでインテグレーションを実行します。以下は、簡単な Java の例になります。
kamel run HelloCamelK.java --dev
integration "hello-camel-k" created
Progress: integration "hello-camel-k" in phase Initialization
Progress: integration "hello-camel-k" in phase Building Kit
Progress: integration "hello-camel-k" in phase Deploying
Progress: integration "hello-camel-k" in phase Running
IntegrationPlatformAvailable for Integration hello-camel-k: camel-k
Integration hello-camel-k in phase Initialization
No IntegrationKitAvailable for Integration hello-camel-k: creating a new integration kit
Integration hello-camel-k in phase Building Kit
IntegrationKitAvailable for Integration hello-camel-k: kit-bq8t5cudeam3u3sj13tg
Integration hello-camel-k in phase Deploying
No CronJobAvailable for Integration hello-camel-k: different controller strategy used (deployment)
DeploymentAvailable for Integration hello-camel-k: deployment name is hello-camel-k
No ServiceAvailable for Integration hello-camel-k: no http service required
No ExposureAvailable for Integration hello-camel-k: no target service found
Integration hello-camel-k in phase Running
[2] Monitoring pod hello-camel-k-866ccb5976-sjh8x[1] Monitoring pod hello-camel-k-866ccb5976-l288p[2] 2020-04-11 14:44:53.691 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextConfigurer@159f197
[2] 2020-04-11 14:44:53.694 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesConfigurer@1f0f1111
[2] 2020-04-11 14:44:53.695 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesDumper@6e0dec4a
[2] 2020-04-11 14:44:53.695 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805
[2] 2020-04-11 14:44:53.712 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805 executed in phase Starting
[2] 2020-04-11 14:44:53.721 INFO [main] RuntimeSupport - Looking up loader for language: java
[2] 2020-04-11 14:44:53.723 INFO [main] RuntimeSupport - Found loader org.apache.camel.k.loader.java.JavaSourceLoader@3911c2a7 for language java from service definition
[2] 2020-04-11 14:44:54.220 INFO [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/i-source-000/HelloCamelK.java?language=java
[2] 2020-04-11 14:44:54.220 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesConfigurer@1f0f1111 executed in phase ConfigureRoutes
[2] 2020-04-11 14:44:54.224 INFO [main] BaseMainSupport - Using properties from: file:/etc/camel/conf/application.properties
[2] 2020-04-11 14:44:54.385 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextConfigurer@159f197 executed in phase ConfigureContext
[2] 2020-04-11 14:44:54.386 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) is starting
[2] 2020-04-11 14:44:54.387 INFO [main] DefaultManagementStrategy - JMX is disabled
[2] 2020-04-11 14:44:54.630 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
[2] 2020-04-11 14:44:54.639 INFO [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
[2] 2020-04-11 14:44:54.643 INFO [main] DefaultCamelContext - Total 1 routes, of which 1 are started
[2] 2020-04-11 14:44:54.643 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in 0.258 seconds
[2] 2020-04-11 14:44:54.644 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
[2] 2020-04-11 14:44:55.671 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from java]
...
$ kamel run HelloCamelK.java --dev
integration "hello-camel-k" created
Progress: integration "hello-camel-k"in phase Initialization
Progress: integration "hello-camel-k"in phase Building Kit
Progress: integration "hello-camel-k"in phase Deploying
Progress: integration "hello-camel-k"in phase Running
IntegrationPlatformAvailable for Integration hello-camel-k: camel-k
Integration hello-camel-k in phase Initialization
No IntegrationKitAvailable for Integration hello-camel-k: creating a new integration kit
Integration hello-camel-k in phase Building Kit
IntegrationKitAvailable for Integration hello-camel-k: kit-bq8t5cudeam3u3sj13tg
Integration hello-camel-k in phase Deploying
No CronJobAvailable for Integration hello-camel-k: different controller strategy used (deployment)
DeploymentAvailable for Integration hello-camel-k: deployment name is hello-camel-k
No ServiceAvailable for Integration hello-camel-k: no http service required
No ExposureAvailable for Integration hello-camel-k: no target service found
Integration hello-camel-k in phase Running
[2] Monitoring pod hello-camel-k-866ccb5976-sjh8x[1] Monitoring pod hello-camel-k-866ccb5976-l288p[2]2020-04-11 14:44:53.691 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.ContextConfigurer@159f197
[2]2020-04-11 14:44:53.694 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesConfigurer@1f0f1111
[2]2020-04-11 14:44:53.695 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.RoutesDumper@6e0dec4a
[2]2020-04-11 14:44:53.695 INFO [main] ApplicationRuntime - Add listener: org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805
[2]2020-04-11 14:44:53.712 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.PropertiesFunctionsConfigurer@794cb805 executed in phase Starting
[2]2020-04-11 14:44:53.721 INFO [main] RuntimeSupport - Looking up loader for language: java[2]2020-04-11 14:44:53.723 INFO [main] RuntimeSupport - Found loader org.apache.camel.k.loader.java.JavaSourceLoader@3911c2a7 for language java from service definition
[2]2020-04-11 14:44:54.220 INFO [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/i-source-000/HelloCamelK.java?language=java
[2]2020-04-11 14:44:54.220 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesConfigurer@1f0f1111 executed in phase ConfigureRoutes
[2]2020-04-11 14:44:54.224 INFO [main] BaseMainSupport - Using properties from: file:/etc/camel/conf/application.properties
[2]2020-04-11 14:44:54.385 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.ContextConfigurer@159f197 executed in phase ConfigureContext
[2]2020-04-11 14:44:54.386 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) is starting
[2]2020-04-11 14:44:54.387 INFO [main] DefaultManagementStrategy - JMX is disabled
[2]2020-04-11 14:44:54.630 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
[2]2020-04-11 14:44:54.639 INFO [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
[2]2020-04-11 14:44:54.643 INFO [main] DefaultCamelContext - Total 1 routes, of which1 are started
[2]2020-04-11 14:44:54.643 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in0.258 seconds
[2]2020-04-11 14:44:54.644 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
[2]2020-04-11 14:44:55.671 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K from java]...
Copy to ClipboardCopied!Toggle word wrapToggle overflow
...
integration "hello-camel-k" updated
...
[3] 2020-04-11 14:45:06.792 INFO [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
[3] 2020-04-11 14:45:06.795 INFO [main] DefaultCamelContext - Total 1 routes, of which 1 are started
[3] 2020-04-11 14:45:06.796 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in 0.323 seconds
[3] 2020-04-11 14:45:06.796 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
[3] 2020-04-11 14:45:07.826 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Ciao Camel K from java]
...
...
integration "hello-camel-k" updated
...
[3]2020-04-11 14:45:06.792 INFO [main] DefaultCamelContext - Route: java started and consuming from: timer://java?period=1s
[3]2020-04-11 14:45:06.795 INFO [main] DefaultCamelContext - Total 1 routes, of which1 are started
[3]2020-04-11 14:45:06.796 INFO [main] DefaultCamelContext - Apache Camel 3.0.1 (CamelContext: camel-k) started in0.323 seconds
[3]2020-04-11 14:45:06.796 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started
[3]2020-04-11 14:45:07.826 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Ciao Camel K from java]...
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Ctrl-C キーを押して、ターミナルでログインを終了します。
関連情報
kamel run コマンドの詳細については、kamel run --help を入力してください。