-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a camel-quarkus example using the quarkus openshift extension
* Moves the camel-quarkus example to camel-quarkus-kubernetes * Adds the openshift extension example as camel-quarkus-openshift * Updates the README files to reference the other example
- Loading branch information
1 parent
c03cb88
commit e853793
Showing
13 changed files
with
472 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!target/*-runner | ||
!target/*-runner.jar | ||
!target/lib/* | ||
!target/quarkus-app/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Hawtio-Enabled Camel Quarkus Example for OpenShift | ||
|
||
This sample application shows how to make it _hawtio-enabled_ with Camel Quarkus. Once deployed on OpenShift, it will be discovered by Hawtio Online. | ||
|
||
## Highlights | ||
|
||
- [pom.xml](pom.xml) | ||
|
||
This project uses the Quarkus [OpenShift](https://quarkus.io/guides/deploying-to-openshift) extension to build a container image and deploy it to an OpenShift cluster. Should the target cluster be a different version of Kubernetes then an [alternative example](https://github.com/hawtio/hawtio-online-examples/camel-quarkus-openshift) is available. | ||
|
||
The most important part in terms of the _hawtio-enabled_ configuration is defined in the `<properties>` 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 | ||
<properties> | ||
<jolokia.protocol>https</jolokia.protocol> | ||
<jolokia.host>*</jolokia.host> | ||
<jolokia.port>8778</jolokia.port> | ||
<jolokia.useSslClientAuthentication>true</jolokia.useSslClientAuthentication> | ||
<jolokia.caCert>/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt</jolokia.caCert> | ||
<jolokia.clientPrincipal.1>cn=hawtio-online.hawtio.svc</jolokia.clientPrincipal.1> | ||
<jolokia.extendedClientCheck>true</jolokia.extendedClientCheck> | ||
<jolokia.discoveryEnabled>false</jolokia.discoveryEnabled> | ||
</properties> | ||
``` | ||
|
||
## How to run locally | ||
|
||
Run in development mode with: | ||
|
||
```console | ||
mvn compile quarkus:dev | ||
``` | ||
|
||
Or build the project and execute the runnable JAR: | ||
|
||
```console | ||
mvn package && java -jar target/quarkus-app/quarkus-run.jar | ||
``` | ||
|
||
### Running with Jolokia agent locally | ||
|
||
You can run this example with Jolokia JVM agent locally as follows: | ||
|
||
```console | ||
java -javaagent:target/quarkus-app/lib/main/org.jolokia.jolokia-agent-jvm-2.0.1-javaagent.jar -jar target/quarkus-app/quarkus-run.jar | ||
``` | ||
|
||
## How to deploy it to OpenShift | ||
|
||
This example is intended to be used by deploying to an OpenShift cluster. | ||
|
||
To deploy it to a cluster, ensure that the console has access to the OpenShift cluster by logging into it. Then execute the following: | ||
|
||
```console | ||
mvn clean package -Dquarkus.kubernetes.deploy=true | ||
``` | ||
After deployment is successful and the pod has started, the application log can be seen on the cluster like this: | ||
|
||
```console | ||
$ oc log hawtio-online-example-camel-quarkus-os-xxxxxxxxx-xxxxx | ||
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:lib/main/org.jolokia.jolokia-agent-jvm-2.1.0-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 "." -jar /deployments/quarkus-run.jar | ||
INFO running in /deployments | ||
I> No access restrictor found, access to any MBean is allowed | ||
Jolokia: Agent started with URL https://10.217.0.156:8778/jolokia/ | ||
__ ____ __ _____ ___ __ ____ ______ | ||
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/ | ||
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ | ||
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/ | ||
2024-09-12 13:37:27,570 INFO [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Apache Camel Quarkus 3.14.0 is starting | ||
2024-09-12 13:37:27,628 INFO [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.7.0 is starting | ||
2024-09-12 13:37:27,740 INFO [org.apa.cam.mai.BaseMainSupport] (main) Auto-configuration summary | ||
2024-09-12 13:37:27,741 INFO [org.apa.cam.mai.BaseMainSupport] (main) [MicroProfilePropertiesSource] camel.context.name=SampleCamel | ||
2024-09-12 13:37:27,848 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Detected: camel-debug JAR (Enabling Camel Debugging) | ||
2024-09-12 13:37:27,994 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.7.0 (SampleCamel) is starting | ||
2024-09-12 13:37:28,801 INFO [org.apa.cam.com.qua.QuartzComponent] (main) Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX | ||
2024-09-12 13:37:28,869 INFO [org.apa.cam.com.qua.QuartzEndpoint] (main) Job Camel_SampleCamel.cron (cron=0/10 * * * * ?, triggerType=CronTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2024-09-12T13:37:30.000+0000 | ||
2024-09-12 13:37:28,992 INFO [org.apa.cam.com.qua.QuartzEndpoint] (main) Job Camel_SampleCamel.simple (cron=null, triggerType=SimpleTriggerImpl, jobClass=CamelJob) is scheduled. Next fire date is 2024-09-12T13:37:28.987+0000 | ||
2024-09-12 13:37:29,140 INFO [org.apa.cam.mai.BaseMainSupport] (main) Property-placeholders summary | ||
2024-09-12 13:37:29,140 INFO [org.apa.cam.mai.BaseMainSupport] (main) [MicroProfilePropertiesSource] quartz.cron=0/10 * * * * ? | ||
2024-09-12 13:37:29,140 INFO [org.apa.cam.mai.BaseMainSupport] (main) [MicroProfilePropertiesSource] quartz.repeatInterval=10000 | ||
2024-09-12 13:37:29,141 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (total:2) | ||
2024-09-12 13:37:29,141 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Started cron (quartz://cron) | ||
2024-09-12 13:37:29,141 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Started simple (quartz://simple) | ||
2024-09-12 13:37:29,142 INFO [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.7.0 (SampleCamel) started in 1s147ms (build:0ms init:0ms start:1s147ms) | ||
2024-09-12 13:37:29,142 INFO [org.apa.cam.imp.deb.DefaultBacklogDebugger] (main) Enabling Camel debugger | ||
2024-09-12 13:37:29,143 INFO [org.apa.cam.com.qua.QuartzComponent] (main) Starting Quartz scheduler: org.quartz.impl.StdScheduler@44af588b | ||
Hello Camel! - simple | ||
2024-09-12 13:37:29,211 INFO [org.apa.cam.imp.deb.DebuggerJmxConnectorService] (Camel (camel-1) thread #1 - DebuggerJMXConnector) Debugger JMXConnector listening at: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel | ||
Hello Camel! - cron | ||
Hello Camel! - simple | ||
Hello Camel! - cron | ||
Hello Camel! - simple | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.hawt.online.examples</groupId> | ||
<artifactId>hawtio-online-examples</artifactId> | ||
<version>1.0.0</version> | ||
</parent> | ||
|
||
<artifactId>hawtio-online-example-camel-quarkus-os</artifactId> | ||
<name>OpenShift Hawtio Online Camel Quarkus Example</name> | ||
<description>Hawtio Online :: Sample OpenShift Camel Quarkus 3.x application</description> | ||
|
||
<properties> | ||
<skipITs>true</skipITs> | ||
|
||
<!-- | ||
The following are defined in the parent pom | ||
* camel-version | ||
* quarkus-version | ||
* jolokia-version | ||
--> | ||
|
||
<!-- | ||
========================================================================== | ||
=== Jolokia agent configuration for the connection with Hawtio Online | ||
========================================================================== | ||
It should use HTTPS and SSL client authentication at minimum. | ||
The client principal should match those the Hawtio Online instance | ||
provides (the default is `hawtio-online.hawtio.svc`). | ||
--> | ||
<jolokia.protocol>https</jolokia.protocol> | ||
<jolokia.host>*</jolokia.host> | ||
<jolokia.port>8778</jolokia.port> | ||
<jolokia.useSslClientAuthentication>true</jolokia.useSslClientAuthentication> | ||
<jolokia.caCert>/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt</jolokia.caCert> | ||
<jolokia.clientPrincipal.1>cn=hawtio-online.hawtio.svc</jolokia.clientPrincipal.1> | ||
<jolokia.extendedClientCheck>true</jolokia.extendedClientCheck> | ||
<jolokia.discoveryEnabled>false</jolokia.discoveryEnabled> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus.platform</groupId> | ||
<artifactId>quarkus-bom</artifactId> | ||
<version>${quarkus-version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus.platform</groupId> | ||
<artifactId>quarkus-camel-bom</artifactId> | ||
<version>${quarkus-version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-openshift</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-quartz</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-stream</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-mock</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
|
||
<!-- | ||
This dependency is mandatory for enabling Camel management | ||
via JMX / Hawtio. | ||
--> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-management</artifactId> | ||
</dependency> | ||
|
||
<!-- | ||
This dependency is required for viewing Camel routes source XML. | ||
--> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-jaxb</artifactId> | ||
</dependency> | ||
|
||
<!-- | ||
To enable Camel plugin debugging feature, add this dependency. | ||
--> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-debug</artifactId> | ||
</dependency> | ||
|
||
<!-- | ||
Include the jolokia agent jvm for access to JMX beans. | ||
--> | ||
<dependency> | ||
<groupId>org.jolokia</groupId> | ||
<artifactId>jolokia-agent-jvm</artifactId> | ||
<version>${jolokia-version}</version> | ||
<classifier>javaagent</classifier> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus.platform</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus-version}</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
<goal>native-image-agent</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<parameters>true</parameters> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>native-mode-not-supported</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<target> | ||
<echo message="!!! WARNING !!!" /> | ||
<echo message="Hawtio does not support Quarkus native mode!" /> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
Oops, something went wrong.