diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 0b495ef..1ce9e9d 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -24,13 +24,7 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} cache: 'maven' - - name: Build - run: | - mvn --batch-mode --no-transfer-progress install -Djkube.build.strategy=docker - - name: List images - run: | - docker images - - name: Push image to Quay.io + - name: Build and push image to Quay.io if: github.event_name == 'push' env: USERNAME: ${{ secrets.QUAY_USERNAME }} @@ -38,14 +32,23 @@ jobs: run: | docker login --help docker login -u $USERNAME -p $PASSWORD quay.io - docker tag quay.io/hawtio/hawtio-online-example-camel-quarkus-kube:latest quay.io/hawtio/hawtio-online-example-camel-quarkus:${{matrix.java}} - docker tag quay.io/hawtio/hawtio-online-example-camel-springboot:latest quay.io/hawtio/hawtio-online-example-camel-springboot:${{matrix.java}} - docker push quay.io/hawtio/hawtio-online-example-camel-quarkus:${{matrix.java}} - docker push quay.io/hawtio/hawtio-online-example-camel-springboot:${{matrix.java}} + mvn --batch-mode --no-transfer-progress -pl 'camel-quarkus-kubernetes' install \ + -Dquarkus.jib.base-jvm-image=registry.access.redhat.com/ubi9/openjdk-${{ matrix.java }}-runtime:latest \ + -Dquarkus.jib.platforms=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \ + -Dquarkus.container-image.name=hawtio-online-example-camel-quarkus \ + -Dquarkus.container-image.tag=${{ matrix.java }} \ + -Dquarkus.container-image.push=true + + mvn --batch-mode --no-transfer-progress -pl 'camel-springboot' package k8s:build k8s:push \ + -Djkube.container-image.from=registry.access.redhat.com/ubi9/openjdk-${{ matrix.java }}:latest \ + -Djkube.container-image.platforms.1=linux/amd64 \ + -Djkube.container-image.platforms.2=linux/arm64 \ + -Djkube.container-image.platforms.3=linux/ppc64le \ + -Djkube.container-image.platforms.4=linux/s390x \ + -Djkube.container-image.name=quay.io/hawtio/hawtio-online-example-camel-springboot:${{ matrix.java }} - if [[ "${{matrix.java}}" == "21" ]]; then - docker tag quay.io/hawtio/hawtio-online-example-camel-quarkus-kube:latest quay.io/hawtio/hawtio-online-example-camel-quarkus:latest - docker push quay.io/hawtio/hawtio-online-example-camel-quarkus:latest - docker push quay.io/hawtio/hawtio-online-example-camel-springboot:latest + if [[ "${{ matrix.java }}" == "21" ]]; then + docker buildx imagetools create -t quay.io/hawtio/hawtio-online-example-camel-quarkus:latest quay.io/hawtio/hawtio-online-example-camel-quarkus:${{ matrix.java }} + docker buildx imagetools create -t quay.io/hawtio/hawtio-online-example-camel-springboot:latest quay.io/hawtio/hawtio-online-example-camel-springboot:${{ matrix.java }} fi diff --git a/camel-springboot/README.md b/camel-springboot/README.md index 7eccc50..023c31e 100644 --- a/camel-springboot/README.md +++ b/camel-springboot/README.md @@ -6,31 +6,21 @@ This sample application shows how to make it hawtio-enabled with Camel Spring Bo - [pom.xml](pom.xml) -This project uses JKube [kubernetes-maven-plugin](https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/) to build a container image and deploy it to a Kubernetes/OpenShift cluster. JKube supports Jolokia out of the box and the default base image already includes Jolokia agent. +This project uses JKube [kubernetes-maven-plugin](https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/) to build a container image and deploy it to a Kubernetes/OpenShift cluster. -All you need to make the application _hawtio-enabled_ is to define additional environment variables to the deployment resource to fine-tune the Jolokia agent options. By default, JKube plugin sets up a Jolokia agent with HTTPS and SSL client authentication enabled. The only necessary configurations are the client principal that matches the Hawtio Online instance (the default is `hawtio-online.hawtio.svc`) and the CA cert to specify `service-ca.crt` instead of the default `ca.crt`. +The most important part in terms of the _hawtio-enabled_ configuration is defined in the `` section. To make it _hawtio-enabled_, the Jolokia agent must be attached to the application with HTTPS and SSL client authentication configured. The client principal should match those the Hawtio Online instance provides (the default is `hawtio-online.hawtio.svc`). ```xml - - org.eclipse.jkube - kubernetes-maven-plugin - ${kubernetes-maven-plugin-version} - - - - - cn=hawtio-online.hawtio.svc - caCert=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - - - - + + https + * + 8778 + true + /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + cn=hawtio-online.hawtio.svc + true + false + ``` ## How to run locally @@ -48,7 +38,7 @@ This example is intended to be used by deploying to a Kubernetes/OpenShift clust To deploy it to a cluster, firstly change the container image name in [pom.xml](pom.xml) to fit your development environment. (The default image name is `quay.io/hawtio/hawtio-online-example-camel-springboot:latest`, which should be pushed to the `hawtio` organisation on [Quay.io](https://quay.io/).) ```xml - quay.io/hawtio/%a:latest + quay.io/hawtio/%a:latest ``` Then build the project and container image: @@ -73,9 +63,10 @@ After deployment is successful and the pod has started, the application log can ```console $ hawtio-online-example-camel-springboot -+ hawtio-online-example-camel-springboot-7f578548d6-s27j4 › spring-boot ++ hawtio-online-example-camel-springboot-7d456c879-pk945 › spring-boot Starting the Java application using /opt/jboss/container/java/run/run-java.sh ... -INFO exec java -javaagent:/usr/share/java/jolokia-jvm-agent/jolokia-jvm.jar=config=/opt/jboss/container/jolokia/etc/jolokia.properties -javaagent:/usr/share/java/prometheus-jmx-exporter/jmx_prometheus_javaagent.jar=9779:/opt/jboss/container/prometheus/etc/jmx-exporter-config.yaml -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp ".:/deployments/*" org.springframework.boot.loader.JarLauncher +INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -javaagent:opt/jolokia-agent-jvm-2.1.1-javaagent.jar=protocol=https,host=*,port=8778,useSslClientAuthentication=true,caCert=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt,clientPrincipal.1=cn=hawtio-online.hawtio.svc,extendedClientCheck=true,discoveryEnabled=false -cp ".:/deployments/*" org.springframework.boot.loader.launch.JarLauncher +INFO running in /deployments _________________________________________ < Hawtio Online Camel Spring Boot Example > ----------------------------------------- @@ -85,22 +76,21 @@ INFO exec java -javaagent:/usr/share/java/jolokia-jvm-agent/jolokia-jvm.jar=con ||----w | || || +2024-10-24T19:03:59.663Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : Starting SampleSpringBootService using Java 21.0.5 with PID 1 (/deployments/hawtio-online-example-camel-springboot-1.0.0.jar started by 1000710000 in /deployments) +2024-10-24T19:03:59.673Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : No active profile set, falling back to 1 default profile: "default" I> No access restrictor found, access to any MBean is allowed -Jolokia: Agent started with URL https://172.17.11.234:8778/jolokia/ -2023-11-23T03:51:12.505Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : Starting SampleSpringBootService using Java 17.0.9 with PID 1 (/deployments/BOOT-INF/classes started by jboss in /deployments) -2023-11-23T03:51:12.512Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : No active profile set, falling back to 1 default profile: "default" -2023-11-23T03:51:15.938Z INFO 1 --- [ main] o.a.c.i.e.DefaultCamelContextExtension : Detected: camel-debug JAR (Enabling Camel Debugging) -2023-11-23T03:51:17.021Z INFO 1 --- [ main] org.xnio : XNIO version 3.8.8.Final -2023-11-23T03:51:17.037Z INFO 1 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.8.8.Final -2023-11-23T03:51:17.077Z INFO 1 --- [ main] org.jboss.threads : JBoss Threads version 3.5.0.Final -2023-11-23T03:51:17.502Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.1.0 (SampleCamelSpringBoot) is starting -2023-11-23T03:51:17.582Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzComponent : Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX -2023-11-23T03:51:17.617Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Using default implementation for ThreadExecutor -2023-11-23T03:51:17.621Z INFO 1 --- [ main] org.quartz.simpl.SimpleThreadPool : Job execution threads will use class loader of thread: main -2023-11-23T03:51:17.632Z INFO 1 --- [ main] org.quartz.core.SchedulerSignalerImpl : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl -2023-11-23T03:51:17.633Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.2 created. -2023-11-23T03:51:17.633Z INFO 1 --- [ main] org.quartz.simpl.RAMJobStore : RAMJobStore initialized. -2023-11-23T03:51:17.638Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler-SampleCamelSpringBoot' with instanceId 'NON_CLUSTERED' +Jolokia: Agent started with URL https://10.128.0.27:8778/jolokia/ +2024-10-24T19:04:02.027Z INFO 1 --- [ main] org.xnio : XNIO version 3.8.16.Final +2024-10-24T19:04:02.037Z INFO 1 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.8.16.Final +2024-10-24T19:04:02.063Z INFO 1 --- [ main] org.jboss.threads : JBoss Threads version 3.5.0.Final +2024-10-24T19:04:02.459Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.8.0 (SampleCamel) is starting +2024-10-24T19:04:02.506Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzComponent : Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX +2024-10-24T19:04:02.529Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Using default implementation for ThreadExecutor +2024-10-24T19:04:02.531Z INFO 1 --- [ main] org.quartz.simpl.SimpleThreadPool : Job execution threads will use class loader of thread: main +2024-10-24T19:04:02.538Z INFO 1 --- [ main] org.quartz.core.SchedulerSignalerImpl : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl +2024-10-24T19:04:02.538Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.2 created. +2024-10-24T19:04:02.539Z INFO 1 --- [ main] org.quartz.simpl.RAMJobStore : RAMJobStore initialized. +2024-10-24T19:04:02.542Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler-SampleCamel' with instanceId 'NON_CLUSTERED' Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. NOT STARTED. Currently in standby mode. @@ -108,20 +98,20 @@ Jolokia: Agent started with URL https://172.17.11.234:8778/jolokia/ Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads. Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered. -2023-11-23T03:51:17.638Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler 'DefaultQuartzScheduler-SampleCamelSpringBoot' initialized from an externally provided properties instance. -2023-11-23T03:51:17.638Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.2 -2023-11-23T03:51:17.651Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzEndpoint : Job Camel_SampleCamelSpringBoot.cron (cron=0/10 * * * * ?, triggerType=CronTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2023-11-23T03:51:20.000+0000 -2023-11-23T03:51:17.688Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzEndpoint : Job Camel_SampleCamelSpringBoot.simple (cron=null, triggerType=SimpleTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2023-11-23T03:51:17.685+0000 -2023-11-23T03:51:17.733Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (started:2) -2023-11-23T03:51:17.733Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started cron (quartz://cron) -2023-11-23T03:51:17.733Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started simple (quartz://simple) -2023-11-23T03:51:17.733Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.1.0 (SampleCamelSpringBoot) started in 230ms (build:0ms init:0ms start:230ms) -2023-11-23T03:51:17.735Z INFO 1 --- [ main] o.a.camel.impl.debugger.BacklogDebugger : Enabling Camel debugger -2023-11-23T03:51:17.735Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzComponent : Starting Quartz scheduler: org.quartz.impl.StdScheduler@72b53f27 -2023-11-23T03:51:17.740Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Scheduler DefaultQuartzScheduler-SampleCamelSpringBoot_$_NON_CLUSTERED started. -2023-11-23T03:51:17.744Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : Started SampleSpringBootService in 6.646 seconds (process running for 7.617) +2024-10-24T19:04:02.542Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler 'DefaultQuartzScheduler-SampleCamel' initialized from an externally provided properties instance. +2024-10-24T19:04:02.542Z INFO 1 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.2 +2024-10-24T19:04:02.557Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzEndpoint : Job Camel_SampleCamel.cron (cron=0/10 * * * * ?, triggerType=CronTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2024-10-24T19:04:10.000+0000 +2024-10-24T19:04:02.579Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzEndpoint : Job Camel_SampleCamel.simple (cron=null, triggerType=SimpleTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2024-10-24T19:04:02.577+0000 +2024-10-24T19:04:02.596Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (total:2) +2024-10-24T19:04:02.596Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started cron (quartz://cron) +2024-10-24T19:04:02.596Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started simple (quartz://simple) +2024-10-24T19:04:02.596Z INFO 1 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.8.0 (SampleCamel) started in 136ms (build:0ms init:0ms start:136ms) +2024-10-24T19:04:02.597Z INFO 1 --- [ main] o.a.c.i.debugger.DefaultBacklogDebugger : Enabling Camel debugger +2024-10-24T19:04:02.598Z INFO 1 --- [ main] o.a.c.component.quartz.QuartzComponent : Starting Quartz scheduler: org.quartz.impl.StdScheduler@3fdede3a +2024-10-24T19:04:02.598Z INFO 1 --- [ main] org.quartz.core.QuartzScheduler : Scheduler DefaultQuartzScheduler-SampleCamel_$_NON_CLUSTERED started. +2024-10-24T19:04:02.599Z INFO 1 --- [ main] i.h.o.e.s.SampleSpringBootService : Started SampleSpringBootService in 3.266 seconds (process running for 3.738) Hello Camel! - simple -2023-11-23T03:51:17.788Z INFO 1 --- [melJMXConnector] o.a.c.c.debug.JmxConnectorService : JMX Connector thread started and listening at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel +2024-10-24T19:04:02.618Z INFO 1 --- [gerJMXConnector] o.a.c.i.d.DebuggerJmxConnectorService : Debugger JMXConnector listening at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel Hello Camel! - cron Hello Camel! - simple Hello Camel! - cron diff --git a/camel-springboot/pom.xml b/camel-springboot/pom.xml index a60e20d..e75a132 100644 --- a/camel-springboot/pom.xml +++ b/camel-springboot/pom.xml @@ -13,9 +13,18 @@ Hawtio Online :: Sample Camel Spring Boot 3.x application - quay.io/hawtio/%a:latest + quay.io/hawtio/%a:latest jib + + https + * + 8778 + true + /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt + cn=hawtio-online.hawtio.svc + true + false @@ -111,6 +120,31 @@ + + org.apache.maven.plugins + maven-dependency-plugin + ${maven-dependency-plugin-version} + + + copy-jolokia-agent + package + + copy + + + + + org.jolokia + jolokia-agent-jvm + ${jolokia-version} + javaagent + + + ${project.basedir}/target + + + + org.springframework.boot spring-boot-maven-plugin @@ -136,19 +170,39 @@ - - - - cn=hawtio-online.hawtio.svc - caCert=/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - - + + + ${jkube.container-image.name} + + registry.access.redhat.com/ubi9/openjdk-21:latest + /deployments + + /deployments + + jolokia-agent + + + + ${project.basedir}/target/jolokia-agent-jvm-${jolokia-version}-javaagent.jar + + opt + + + + + + /deployments + org.springframework.boot.loader.launch.JarLauncher + -javaagent:opt/jolokia-agent-jvm-${jolokia-version}-javaagent.jar=protocol=${jolokia.protocol},host=${jolokia.host},port=${jolokia.port},useSslClientAuthentication=${jolokia.useSslClientAuthentication},caCert=${jolokia.caCert},clientPrincipal.1=${jolokia.clientPrincipal.1},extendedClientCheck=${jolokia.extendedClientCheck},discoveryEnabled=${jolokia.discoveryEnabled} + + + 8080 + 8778 + 9779 + + + + diff --git a/pom.xml b/pom.xml index 5de0f4f..02b64a1 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ 3.1.0 3.4.0 3.13.0 + 3.8.0 3.5.0 3.5.0