이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 8. Setting up Quarkus applications for HawtIO Online with Jolokia


This section describes the enabling of monitoring of a Quarkus application by HawtIO. It starts from first principles in setting up a simple example application. However, should a Quarkus application already have been implemented then skip to "Enabling Jolokia Java-Agent on the Example Quarkus Application".

For convenience, an example project based on this documentation has already been implemented and published here. Simply clone its parent repository and jump to "Deployment of the HawtIO-Enabled Quarkus Application to OpenShift”.

Explanation of Hawtio Online Component

  • Any interactions either from users or Hawtio Next are communicated with the HTTP protocol to an Nginx web server
  • The Nginx web server is the outward-facing interface and the only sub-component visible to external consumers
  • When a request is made, the Nginx web server hands off to the internal Gateway component, which serves 2 distinct purposes:

    • Master-Guard Agent

      • Any request directed towards the target Master Cluster API Server (OpenShift) must pass through this component where checks are made to ensure the requested endpoint URL is approved. URLs that are not approved, eg. requests to secrets or configmaps (potentially security sensitive), are rejected;
    • Jolokia Agent

      • Since pods reside on the Master Cluster, ultimately requests for Jolokia information from pods must also be protected and handled in a secure manner.
      • This agent is responsible for converting a request from a client into the correct form for transmission to the target pod internally and passing the response back to the client.

8.1. Setting up an example Quarkus Application

  1. For a new Quarkus application, the maven quarkus quick-start is available, eg.

    mvn com.redhat.quarkus.platform:quarkus-maven-plugin:<quarkus.platform.version>:create\
    -DprojectGroupId=org.hawtio \
    -DprojectArtifactId=quarkus-helloworld \
    -Dextensions='openshift,camel-quarkus-quartz'
    Copy to Clipboard Toggle word wrap
    Note

    Use latest quarkus.platform.version from the Camel Quarkus official documentation.

    1. Use the quarkus-maven-plugin to generate the project scaffolding
    2. Set the project maven groupId to org.hawtio and customize as appropriate
    3. Set the project maven artifactId to quarkus-helloworld and customize as appropriate
    4. Use the following Quarkus extensions:

      1. openshift: Enables maven to deploy to local OpenShift cluster;
      2. camel-quarkus-quartz: Enables the Camel extension quartz for use in the example Quarkus application
    5. Execute the quick-start to create the scaffolding for the Quarkus project and then allow further customization for individual applications.
  2. To build and deploy the application to OpenShift, the following properties should be specified in the file src/main/resources/application.properties (see related documentation).

      # Set the Docker build strategy
      quarkus.openshift.build-strategy=docker
    
      # Expose the service to create an OpenShift Container Platform route
      quarkus.openshift.route.expose=true
    Copy to Clipboard Toggle word wrap

8.2. Implementing an Example Camel Quarkus Application

  1. For this example, a simple Camel ‘hello-world’ Quarkus application is to be implemented. Add the file src/main/java/org/hawtio/SampleCamelRoute.java to the project with the following content:

    package org.hawtio;
    
    import jakarta.enterprise.context.ApplicationScoped;
    import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
    
    @ApplicationScoped
    public class SampleCamelRoute extends EndpointRouteBuilder
    {
    
    	@Override
    	public void configure()
    	{
    		from(quartz("cron").cron("{{quartz.cron}}")).routeId("cron")
    			.setBody().constant("Hello Camel! - cron")
    			.to(stream("out"))
    			.to(mock("result"));
    
         	from("quartz:simple?trigger.repeatInterval={{quartz.repeatInterval}}").routeId("simple")
    			.setBody().constant("Hello Camel! - simple")
    			.to(stream("out"))
    			.to(mock("result"));
    	}
    }
    Copy to Clipboard Toggle word wrap
    1. This example logs "Hello Camel …​" entries in the container log via a Camel route.
  2. Modify the src/main/resources/application.properties file with the following properties:

      # Camel
      camel.context.name = SampleCamel
    
      # Uncomment the following to enable the Camel plugin Trace tab
      #camel.main.tracing = true
      #camel.main.backlogTracing = true
      #camel.main.useBreadcrumb = true
    
      # Uncomment to enable debugging of the application and in turn
      # enables the Camel plugin Debug tab even in non-development
      # environment
      #quarkus.camel.debug.enabled = true
    
      # Define properties for the Camel quartz component used in the
      # example
      quartz.cron = 0/10 * * * * ?
      quartz.repeatInterval = 10000
    Copy to Clipboard Toggle word wrap
  3. Add the following dependencies to the <dependencies> section of file pom.xml. These are required due to the route defined in src/main/java/org/hawtio/SampleCamelRoute.java; these will need to be modified if the Camel route added to the application is changed:

    <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>
    Copy to Clipboard Toggle word wrap

8.3. Enabling Jolokia Java-Agent on the Example Quarkus Application

  1. In order to ensure that maven properties can be passed through to the src/main/resources/application.properties file, the following should be added to the <build> section of the file pom.xml:

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    Copy to Clipboard Toggle word wrap
  2. Add the following Jolokia properties to the <properties> section of the file pom.xml. These will be used to configure the running jolokia java-agent in the Quarkus container (for an explanation of the properties, please refer to the Jolokia JVM Agent documentation):

      <properties>
      	...
    
      	<!-- The current HawtIO Jolokia Version -->
      	<jolokia-version>2.2.9.redhat-00001</jolokia-version>
    
      	<!--
    
        ===============================================================
        === Jolokia agent configuration for the connection with HawtIO
        ===============================================================
    
    	It should use HTTPS and SSL client authentication at minimum.
    	The client principal should match those the HawtIO 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>
    Copy to Clipboard Toggle word wrap
  3. Add the following dependencies to the <dependencies> section of the file pom.xml:

    <!--
    	This dependency is required for enabling Camel management via JMX / HawtIO.
    -->
    <dependency>
    	<groupId>org.apache.camel.quarkus</groupId>
    	<artifactId>camel-quarkus-management</artifactId>
    </dependency>
    
    <!--
    	This dependency is optional for monitoring with HawtIO but is required for HawtIO view the Camel routes source XML.
    -->
    <dependency>
    	<groupId>org.apache.camel.quarkus</groupId>
    	<artifactId>camel-quarkus-jaxb</artifactId>
    </dependency>
    
    <!--
    	Add this optional dependency, to enable Camel plugin debugging feature.
    -->
    <dependency>
    	<groupId>org.apache.camel.quarkus</groupId>
    	<artifactId>camel-quarkus-debug</artifactId>
    </dependency>
    
    <!--
    	This dependency is required to 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>
    Copy to Clipboard Toggle word wrap
  4. With maven property filtering implemented, the ${jolokia…​} environment variables should be passed-through from the pom.xml during the building of the application. The purpose of this property is to append a JVM option to the executing process of the container that runs the jolokia java-agent. Modify the src/main/resources/application.properties file with the following property:

    # Enable the jolokia java-agent on the quarkus application
    quarkus.openshift.env.vars.JAVA_OPTS_APPEND=-javaagent:lib/main/org.jolokia.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}
    Copy to Clipboard Toggle word wrap

8.4. Exposing the Jolokia Port from the Quarkus Container for Discovery by HawtIO

  1. For HawtIO to discover the deployed application, a port named jolokia must be present on the executing container. Therefore, it is necessary to add the following properties in the src/main/resources/application.properties file:

    # Define the Jolokia port on the container for HawtIO access
    quarkus.openshift.ports.jolokia.container-port=${jolokia.port}
    quarkus.openshift.ports.jolokia.protocol=TCP
    Copy to Clipboard Toggle word wrap

8.5. Deployment of the HawtIO-Enabled Quarkus Application to OpenShift

Pre-requsites:

  1. Command-line (CLI) is already logged-in to the OpenShift cluster and the project is selected.
  2. When all files have been configured, the following maven command can be executed:

    ./mvnw clean package -Dquarkus.kubernetes.deploy=true
    Copy to Clipboard Toggle word wrap
  3. Verify that the Quarkus application is running correctly using the Verification steps detailed here.
  4. Assuming the application is running correctly, the new Quarkus application should be discovered by an HawtIO instance (depending on its mode - 'Namespace' mode requires it to be in the same project). The new container should be displayed like in the following screenshot:

    quarkus discovered app
  5. By clicking Connect, the Quarkus application can be examined by HawtIO.

    connected quarkus app

See also:

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동