Running an Integration

After completing the installation you should be able to run an Integration containing a Camel DSL application. The most basic configuration required is to wrap a Camel route into the Integration custom resource. Let’s start with a java DSL Camel application:

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: my-integration
spec:
  sources:
  - content: |
      import org.apache.camel.builder.RouteBuilder;

      public class Test extends RouteBuilder {
          @Override
          public void configure() throws Exception {
              from("timer:java?period=1000")
                  .setBody()
                      .simple("Hello Camel from ${routeId}")
                  .log("${body}");
          }
      }
    name: Test.java

Save the above as my-integration.yaml and apply with kubectl apply -f my-integration.yaml. Once the resource is stored in the cloud, the operator will take care to build, deploy and run the Camel application for you.

You can monitor the Integration with kubectl get it -w:

NAME             PHASE          READY   RUNTIME PROVIDER   RUNTIME VERSION   CATALOG VERSION   KIT                        REPLICAS
my-integration   Building Kit           quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg
my-integration   Deploying              quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg
my-integration   Running        False   quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg   0
my-integration   Running        False   quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg   1
my-integration   Running        False   quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg   1
my-integration   Running        True    quarkus            3.8.1             3.8.1             kit-crbekb6n5tgc73cb1tkg   1
we’re using the shortname it which can be used instead longer integration

The first time you run the application it may takes some minute as it needs to download dependencies and build the base images that will be reused later. You may notice certain parameters like the phase and the readiness of the application. You can also see the runtime information and the number or replicas running for this application. You will learn more about IntegrationKit and other aspects in the other sections of the documentations.

You can now check the Pods which are running the application and log to see what’s going on:

kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
my-integration-7d86444646-62497   1/1     Running   0          118s

kubectl logs my-integration-7d86444646-62497
2024-09-03 10:53:04,370 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 3.8.1
2024-09-03 10:53:04,378 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
2024-09-03 10:53:04,389 INFO  [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.4.1 is starting
2024-09-03 10:53:04,973 INFO  [org.apa.cam.k.sup.SourcesSupport] (main) Loading routes from: SourceDefinition{name='Test', language='java', type='source', location='file:/etc/camel/sources/Test.java', }
2024-09-03 10:53:15,275 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) is starting
2024-09-03 10:53:15,471 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (started:1)
2024-09-03 10:53:15,471 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://java)
2024-09-03 10:53:15,472 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) started in 194ms (build:0ms init:0ms start:194ms)
2024-09-03 10:53:15,479 INFO  [io.quarkus] (main) camel-k-integration 2.5.0-SNAPSHOT on JVM (powered by Quarkus 3.8.3) started in 30.798s.
2024-09-03 10:53:15,480 INFO  [io.quarkus] (main) Profile prod activated.
2024-09-03 10:53:15,480 INFO  [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-java-joor-dsl, camel-k-core, camel-k-runtime, camel-kubernetes, camel-timer, cdi, kubernetes-client, smallrye-context-propagation, vertx]
2024-09-03 10:53:16,478 INFO  [route1] (Camel (camel-1) thread #1 - timer://java) Hello Camel from route1
2024-09-03 10:53:17,470 INFO  [route1] (Camel (camel-1) thread #1 - timer://java) Hello Camel from route1
...
if the above example failed, have a look at how to troubleshoot a Camel K Integration.

YAML DSL

In the example above we’ve seen how to run a Java DSL Camel application. You can use any other Camel DSL compatible in the same way. However, the Yaml DSL is a bit peculiar as it is a first class citizen for Camel K. Since the Integration is already a Yaml specification, then, Camel K provides a first class mechanism to embed the Yaml DSL in the Integration .spec.flows:

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: my-it
spec:
  flows:
  - from:
      parameters:
        period: "1000"
      steps:
      - setBody:
          simple: Hello Camel from ${routeId}
      - log: ${body}
      uri: timer:yaml

You can see the specification is a lot neater, so, try choosing Yaml DSL whenever it’s possible.

Using Kamel CLI

Camel K works very well with any Kubernetes compatible user interface (such as CLI as kubectl, oc or any other visual tooling). However we do provide a simple CLI that helps you performing most of the Integration works in an easier fashion: it’s kamel CLI.