Le socle Camel-K est un middleware intégré type ESB, Enterprise Services Bus, basé sur le framework Camel. Il est géré par la communauté Apache. Sa particularité est de s’exécuter très très facilement dans un cluster Kubernetes.
Si vous appréciez le framework Camel et que vous aimez la simplicité, Camel-K est fait pour vous :-D.
Au sein de Middleware Solutions, nous gérons pour nos clients ce socle technologique sur Azure ou sur Google Cloud Platform. Je vous expose ici une de nos procédures: l’installation complète pour déployer ce super runtime sur Google Cloud Platform.
Pré-requis:
- un registre Docker sur Google Artifactory dans votre projet PROJECT-ID:
- localisation: exemple, europe-west1-docker.pkg.dev
- nom: REPO-ID
- un Cluster kubernetes sur Google Kubernetes Engine.
- vous être connecté via kubectl.
Préparation du compte de service
Déclarer un compte de service dans IAM, Identity and Access Management:
gcloud iam service-accounts create kamel-integrator \
--display-name "Kamel integrator"
Lui donner les droits de gestion d’écrire dans les registres du projet:
gcloud projects add-iam-policy-binding <PROJECT-ID> \
--member="serviceAccount:kamel-integrator@<PROJECT-ID>.iam.gserviceaccount.com" \
--role="roles/artifactregistry.writer"
Récupérer le fichier de sa clé que nous utiliserons pour la connexion. Le fichier key.json est généré:
gcloud iam service-accounts keys create key.json \
--iam-account kamel-integrator@<PROJECT-ID>.iam.gserviceaccount.com
Installer Camel-K
Installer Camel-K se réalise en 1 seule ligne de commande. Nous utiliserons la clé précédente pour le relier au dépôt d’images docker:
kamel install \
--olm false \
--registry europe-west1-docker.pkg.dev \
--organization <PROJECT-ID>/<REPO-ID> \
--registry-auth-username _json_key \
--registry-auth-password "$(cat key.json)" \
--force
Notre infrastructure ESB Camel est prête 😀 !
Déployer une application de test.
Nous cet exemple, nous utiliserons une application de test issue de: https://github.com/apache/camel-k-examples/, basic:
// camel-k: language=java
import org.apache.camel.builder.RouteBuilder;
public class Basic extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:java?period=1000")
.setHeader("example")
.constant("Java")
.setBody()
.simple("Hello World! Camel K route written in ${header.example}.")
.to("log:info");
}
}
La déployer et l’exécuter se fait aussi en 1 seule commande.
kamel run Basic.java --dev
Les traces sont celles de l’environnement créé sur votre cluster distant GKE:
Integration "basic" created
Progress: integration "basic" in phase Initialization
Integration Kit "kit-cq61263o30ec73cu2s4g", created by Integration "basic", changed phase to "Error"
Progress: integration "basic" in phase Building Kit
Condition "IntegrationPlatformAvailable" is "True" for Integration basic: fake-apps/camel-k
Condition "TraitInfo" is "True" for Integration basic: Applied traits: platform,camel,deployer
Integration "basic" in phase "Initialization"
Condition "TraitInfo" is "True" for Integration basic: Applied traits: init,camel,dependencies,deployer,gc,container,owner
Integration "basic" in phase "Building Kit"
Condition "TraitInfo" is "True" for Integration basic: Applied traits: camel,deployer,quarkus
Condition "IntegrationKitAvailable" is "False" for Integration basic: creating a new integration kit
Integration Kit "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Build Submitted"
Build "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Scheduling"
Build "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Pending"
Build "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Running"
Integration Kit "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Build Running"
Build "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Succeeded"
Integration Kit "kit-cq6203mdknbs73d8sefg", created by Integration "basic", changed phase to "Ready"
Progress: integration "basic" in phase Deploying
Condition "IntegrationKitAvailable" is "True" for Integration basic: kit-cq6203mdknbs73d8sefg
Integration "basic" in phase "Deploying"
Progress: integration "basic" in phase Running
Condition "DeploymentAvailable" is "True" for Integration basic: deployment name is basic
Condition "TraitInfo" is "True" for Integration basic: Applied traits: camel,environment,logging,deployer,deployment,gc,container,mount,pull-secret,quarkus,jvm,owner
Condition "Ready" is "False" for Integration basic: 0/1 updated replicas
Integration "basic" in phase "Running"
(combined from similar events): Condition "Ready" is "False" for Integration basic: 0/1 ready replicas
[1] Monitoring pod basic-79fbbfb777-mxpw8
[1] exec java -cp ./resources:/etc/camel/application.properties:/etc/camel/conf.d/_resources:/etc/camel/resources:/etc/camel/sources/Basic.java:dependencies/app/camel-k-integration-2.3.3.jar:dependencies/lib/boot/io.github.crac.org-crac-0.1.3.jar:dependencies/lib/boot/io.quarkus.quarkus-bootstrap-runner-3.8.3.jar:dependencies/lib/boot/io.quarkus.quarkus-development-mode-spi-3.8.3.jar:dependencies/lib/boot/io.quarkus.quarkus-vertx-latebound-mdc-provider-3.8.3.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-constraint-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-cpu-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-expression-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-function-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-io-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-net-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-os-2.1.2.jar:dependencies/lib/boot/io.smallrye.common.smallrye-common-ref-2.1.2.jar:dependencies/lib/boot/jakarta.json.jakarta.json-api-2.1.3.jar:dependencies/lib/boot/org.eclipse.parsson.parsson-1.1.5.jar:dependencies/lib/boot/org.jboss.logging.jboss-logging-3.5.3.Final.jar:dependencies/lib/boot/org.jboss.logmanager.jboss-logmanager-3.0.4.Final.jar:dependencies/lib/main/com.aayushatharva.brotli4j.brotli4j-1.16.0.jar:dependencies/lib/main/com.aayushatharva.brotli4j.native-linux-x86_64-1.16.0.jar:dependencies/lib/main/com.aayushatharva.brotli4j.service-1.16.0.jar:dependencies/lib/main/com.fasterxml.jackson.core.jackson-annotations-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.core.jackson-core-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.core.jackson-databind-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.dataformat.jackson-dataformat-yaml-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.datatype.jackson-datatype-jdk8-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.datatype.jackson-datatype-jsr310-2.16.1.jar:dependencies/lib/main/com.fasterxml.jackson.module.jackson-module-parameter-names-2.16.1.jar:dependencies/lib/main/com.github.mifmif.generex-1.0.2.jar:dependencies/lib/main/commons-codec.commons-codec-1.16.1.jar:dependencies/lib/main/commons-io.commons-io-2.15.1.jar:dependencies/lib/main/dk.brics.automaton.automaton-1.11-8.jar:dependencies/lib/main/io.fabric8.kubernetes-client-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-client-api-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-httpclient-vertx-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-admissionregistration-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-apiextensions-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-apps-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-autoscaling-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-batch-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-certificates-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-common-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-coordination-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-core-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-discovery-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-events-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-extensions-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-flowcontrol-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-gatewayapi-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-metrics-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-networking-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-node-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-policy-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-rbac-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-resource-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-scheduling-6.10.0.jar:dependencies/lib/main/io.fabric8.kubernetes-model-storageclass-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-client-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-client-api-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-clusterautoscaling-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-config-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-console-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-installer-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-machine-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-machineconfig-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-monitoring-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-operatorhub-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-storageversionmigrator-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-tuned-6.10.0.jar:dependencies/lib/main/io.fabric8.openshift-model-whereabouts-6.10.0.jar:dependencies/lib/main/io.fabric8.zjsonpatch-0.3.0.jar:dependencies/lib/main/io.netty.netty-buffer-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-dns-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-haproxy-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-http-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-http2-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-codec-socks-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-common-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-handler-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-handler-proxy-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-resolver-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-resolver-dns-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-transport-4.1.107.Final.jar:dependencies/lib/main/io.netty.netty-transport-native-unix-common-4.1.107.Final.jar:dependencies/lib/main/io.quarkus.arc.arc-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-arc-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-core-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-fs-util-0.0.10.jar:dependencies/lib/main/io.quarkus.quarkus-jackson-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-jsonp-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-kubernetes-client-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-kubernetes-client-internal-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-logging-json-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-mutiny-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-netty-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-smallrye-context-propagation-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-vertx-3.8.3.jar:dependencies/lib/main/io.quarkus.quarkus-virtual-threads-3.8.3.jar:dependencies/lib/main/io.smallrye.common.smallrye-common-annotation-2.1.2.jar:dependencies/lib/main/io.smallrye.common.smallrye-common-classloader-2.1.2.jar:dependencies/lib/main/io.smallrye.common.smallrye-common-vertx-context-2.1.2.jar:dependencies/lib/main/io.smallrye.config.smallrye-config-3.5.4.jar:dependencies/lib/main/io.smallrye.config.smallrye-config-common-3.5.4.jar:dependencies/lib/main/io.smallrye.config.smallrye-config-core-3.5.4.jar:dependencies/lib/main/io.smallrye.config.smallrye-config-source-yaml-3.5.4.jar:dependencies/lib/main/io.smallrye.reactive.mutiny-2.5.8.jar:dependencies/lib/main/io.smallrye.reactive.mutiny-smallrye-context-propagation-2.5.8.jar:dependencies/lib/main/io.smallrye.reactive.smallrye-mutiny-vertx-core-3.10.0.jar:dependencies/lib/main/io.smallrye.reactive.smallrye-mutiny-vertx-runtime-3.10.0.jar:dependencies/lib/main/io.smallrye.reactive.vertx-mutiny-generator-3.10.0.jar:dependencies/lib/main/io.smallrye.smallrye-context-propagation-2.1.0.jar:dependencies/lib/main/io.smallrye.smallrye-context-propagation-api-2.1.0.jar:dependencies/lib/main/io.smallrye.smallrye-context-propagation-storage-2.1.0.jar:dependencies/lib/main/io.smallrye.smallrye-fault-tolerance-vertx-6.2.6.jar:dependencies/lib/main/io.vertx.vertx-auth-common-4.5.4.jar:dependencies/lib/main/io.vertx.vertx-codegen-4.5.4.jar:dependencies/lib/main/io.vertx.vertx-core-4.5.4.jar:dependencies/lib/main/io.vertx.vertx-web-client-4.5.4.jar:dependencies/lib/main/io.vertx.vertx-web-common-4.5.4.jar:dependencies/lib/main/jakarta.activation.jakarta.activation-api-2.1.2.jar:dependencies/lib/main/jakarta.annotation.jakarta.annotation-api-2.1.1.jar:dependencies/lib/main/jakarta.el.jakarta.el-api-5.0.1.jar:dependencies/lib/main/jakarta.enterprise.jakarta.enterprise.cdi-api-4.0.1.jar:dependencies/lib/main/jakarta.enterprise.jakarta.enterprise.lang-model-4.0.1.jar:dependencies/lib/main/jakarta.inject.jakarta.inject-api-2.0.1.jar:dependencies/lib/main/jakarta.interceptor.jakarta.interceptor-api-2.1.0.jar:dependencies/lib/main/jakarta.transaction.jakarta.transaction-api-2.0.1.jar:dependencies/lib/main/jakarta.xml.bind.jakarta.xml.bind-api-4.0.1.jar:dependencies/lib/main/org.apache.camel.camel-api-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-base-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-base-engine-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-bean-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-cloud-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-cluster-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-componentdsl-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-catalog-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-engine-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-languages-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-model-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-processor-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-core-reifier-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-dsl-support-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-endpointdsl-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-java-joor-dsl-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-joor-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-kubernetes-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-log-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-main-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-management-api-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-microprofile-config-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-support-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-timer-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-tooling-model-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-util-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-util-json-4.4.1.jar:dependencies/lib/main/org.apache.camel.camel-xml-jaxp-util-4.4.1.jar:dependencies/lib/main/org.apache.camel.k.camel-k-core-3.8.1.jar:dependencies/lib/main/org.apache.camel.k.camel-k-core-api-3.8.1.jar:dependencies/lib/main/org.apache.camel.k.camel-k-core-support-3.8.1.jar:dependencies/lib/main/org.apache.camel.k.camel-k-runtime-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-bean-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-core-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-core-cloud-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-java-joor-dsl-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-kubernetes-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-log-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-support-commons-logging-3.8.1.jar:dependencies/lib/main/org.apache.camel.quarkus.camel-quarkus-timer-3.8.1.jar:dependencies/lib/main/org.apache.commons.commons-compress-1.26.1.jar:dependencies/lib/main/org.apache.commons.commons-lang3-3.14.0.jar:dependencies/lib/main/org.eclipse.microprofile.config.microprofile-config-api-3.0.3.jar:dependencies/lib/main/org.eclipse.microprofile.context-propagation.microprofile-context-propagation-api-1.3.jar:dependencies/lib/main/org.jboss.logging.commons-logging-jboss-logging-1.0.0.Final.jar:dependencies/lib/main/org.jboss.logging.jboss-logging-annotations-2.2.1.Final.jar:dependencies/lib/main/org.jboss.slf4j.slf4j-jboss-logmanager-2.0.0.Final.jar:dependencies/lib/main/org.jboss.threads.jboss-threads-3.5.1.Final.jar:dependencies/lib/main/org.jooq.joor-0.9.15.jar:dependencies/lib/main/org.slf4j.slf4j-api-2.0.6.jar:dependencies/lib/main/org.snakeyaml.snakeyaml-engine-2.7.jar:dependencies/lib/main/org.wildfly.common.wildfly-common-1.7.0.Final.jar:dependencies/lib/main/org.yaml.snakeyaml-2.2.jar:dependencies/quarkus-app-dependencies.txt:dependencies/quarkus-run.jar:dependencies/quarkus/generated-bytecode.jar:dependencies/quarkus/quarkus-application.dat:dependencies/quarkus/transformed-bytecode.jar io.quarkus.bootstrap.runner.QuarkusEntryPoint
(combined from similar events): Condition "Ready" is "True" for Integration basic: 1/1 ready replicas
Condition "Ready" is "True" for Integration basic: 1/1 ready replicas
[1] 2024-07-08 17:22:00,230 INFO [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 3.8.1
[1] 2024-07-08 17:22:00,234 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
[1] 2024-07-08 17:22:00,236 INFO [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.4.1 is starting
[1] 2024-07-08 17:22:00,268 INFO [org.apa.cam.k.sup.SourcesSupport] (main) Loading routes from: SourceDefinition{name='Basic', language='java', type='source', location='file:/etc/camel/sources/Basic.java', }
[1] 2024-07-08 17:22:01,476 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) is starting
[1] 2024-07-08 17:22:01,488 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (started:1)
[1] 2024-07-08 17:22:01,489 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Started route1 (timer://java)
[1] 2024-07-08 17:22:01,489 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.4.1 (camel-1) started in 12ms (build:0ms init:0ms start:12ms)
[1] 2024-07-08 17:22:01,495 INFO [io.quarkus] (main) camel-k-integration 2.3.3 on JVM (powered by Quarkus 3.8.3) started in 2.923s.
[1] 2024-07-08 17:22:01,496 INFO [io.quarkus] (main) Profile prod activated.
[1] 2024-07-08 17:22:01,497 INFO [io.quarkus] (main) Installed features: [camel-bean, camel-core, camel-java-joor-dsl, camel-k-core, camel-k-runtime, camel-kubernetes, camel-log, camel-timer, cdi, kubernetes-client, smallrye-context-propagation, vertx]
[1] 2024-07-08 17:22:02,494 INFO [info] (Camel (camel-1) thread #1 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]
[1] 2024-07-08 17:22:03,488 INFO [info] (Camel (camel-1) thread #1 - timer://java) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World! Camel K route written in Java.]
Déploiement des images
Objectif atteint ! Les images sont automatiquement déployées dans le dépôt REPO-ID de Artifactory.