Skip to content

Commit

Permalink
🔀 Upgrade to latest Quarkus, Strimizi, Apicurio Registry Operators an…
Browse files Browse the repository at this point in the history
…d others (#1)

Main changes included:

* ⚡ Updated to Quarkus 1.13.7.Final
* ⬆️ Upgrade to Strimzi 0.24.0 (Apache Kafka 2.7)
* ⬆️ Upgrade to Apicurio Registry 2.0.1.Final
* ♻️ Refactored Kafka config to use latest version of Apicurio Serdes
* ⬆️ Update JKube (kubernetes|openshift)-maven-plugin to 1.3.0
* 📝 How to deploy in Minikube or CodeReady Containers
* 📝 Fix minor typos in readme
* 📝 Changed Maven commands to use mvnw cli

Co-authored-by: manusa <[email protected]>
  • Loading branch information
rmarting and manusa authored Jun 29, 2021
1 parent f0ccafa commit 6ee4987
Show file tree
Hide file tree
Showing 24 changed files with 459 additions and 504 deletions.
182 changes: 115 additions & 67 deletions README.md

Large diffs are not rendered by default.

110 changes: 72 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.jromanmartin.kafka</groupId>
<artifactId>kafka-clients-quarkus-sample</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencyManagement>
Expand All @@ -23,23 +23,23 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.parameters>true</maven.compiler.parameters>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<!-- Kafka Clients -->
<kafka-clients.version>2.5.0</kafka-clients.version>
<kafka-clients.version>2.7.0</kafka-clients.version>
<!-- Avro -->
<avro.version>1.10.1</avro.version>
<avro.version>1.10.2</avro.version>
<!-- Apicurio Registry -->
<apicurio.version>1.3.2.Final</apicurio.version>
<!--<apicurio.registry.url>http://localhost:8080/api</apicurio.registry.url>-->
<!-- <apicurio.registry.url>http://service-registry.amq-streams-demo.apps-crc.testing/api</apicurio.registry.url>-->
<apicurio.registry.url>http://service-registry.amq-streams-demo.apps.selae.sandbox1805.opentlc.com/api</apicurio.registry.url>
<apicurio.version>2.0.1.Final</apicurio.version>
<!--<apicurio.registry.url>http://localhost:8080/apis/registry/v2</apicurio.registry.url>-->
<apicurio.registry.url>http://service-registry.amq-streams-demo.apps-crc.testing/apis/registry/v2</apicurio.registry.url>
<!-- JKube -->
<jkube.enricher.jkube-service.type>NodePort</jkube.enricher.jkube-service.type>
<jkube.generator.name>${project.artifactId}:${project.version}</jkube.generator.name>
<jkube.generator.quarkus.webPort>8181</jkube.generator.quarkus.webPort>
<!-- Quarkus -->
<quarkus.platform.version>1.10.5.Final</quarkus.platform.version>
<!-- Quarkus Extensions -->
<quarkiverse.apicurio.version>0.0.1</quarkiverse.apicurio.version>
<quarkus.platform.version>1.13.7.Final</quarkus.platform.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -83,23 +83,11 @@
<artifactId>quarkus-avro</artifactId>
</dependency>

<dependency>
<groupId>io.quarkiverse.apicurio</groupId>
<artifactId>quarkiverse-apicurio-registry-client</artifactId>
<version>${quarkiverse.apicurio.version}</version>
</dependency>

<!-- Apicurio Serializers/Deserializers -->
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-utils-serde</artifactId>
<artifactId>apicurio-registry-serdes-avro-serde</artifactId>
<version>${apicurio.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.interceptor</groupId>
<artifactId>jboss-interceptors-api_1.2_spec</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Test Dependencies -->
Expand All @@ -115,14 +103,32 @@
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>${maven.compiler.parameters}</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>

<!-- Avro Maven Plug-In to generate classes from schemas (files *.avsc) -->
<plugin>
<groupId>org.apache.avro</groupId>
Expand Down Expand Up @@ -153,9 +159,10 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<!-- Added the generated source folder as source path to compile classes -->
<phase>generate-sources</phase>
<goals>
Expand All @@ -174,6 +181,7 @@
</build>

<profiles>
<!-- Apicurio Registry -->
<profile>
<id>apicurio</id>
<build>
Expand All @@ -190,17 +198,42 @@
</goals>
<configuration>
<registryUrl>${apicurio.registry.url}</registryUrl>
<artifactType>AVRO</artifactType>
<artifacts>
<!-- Schema definition for RecordIdStrategy strategy -->
<io.jromanmartin.kafka.schema.avro.Message>${project.basedir}/src/main/resources/schemas/message.avsc</io.jromanmartin.kafka.schema.avro.Message>
<!-- Online -->
<!-- Schema definition for SimpleTopicIdStrategy strategy -->
<messages>${project.basedir}/src/main/resources/schemas/message.avsc</messages>
<artifact>
<groupId>default</groupId>
<artifactId>messages</artifactId>
<type>AVRO</type>
<file>
${project.basedir}/src/main/resources/schemas/message.avsc
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<canonicalize>true</canonicalize>
</artifact>

<!-- Schema definition for TopicIdStrategy strategy -->
<messages-value>${project.basedir}/src/main/resources/schemas/message.avsc</messages-value>
<!-- Schema definition for TopicRecordIdStrategystrategy -->
<messages-io.jromanmartin.kafka.schema.avro.Message>${project.basedir}/src/main/resources/schemas/message.avsc</messages-io.jromanmartin.kafka.schema.avro.Message>
<artifact>
<groupId>default</groupId>
<artifactId>messages-value</artifactId>
<type>AVRO</type>
<file>
${project.basedir}/src/main/resources/schemas/message.avsc
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<canonicalize>true</canonicalize>
</artifact>

<!-- Schema definition for RecordIdStrategy strategy -->
<artifact>
<groupId>io.jromanmartin.kafka.schema.avro</groupId>
<artifactId>Message</artifactId>
<type>AVRO</type>
<file>
${project.basedir}/src/main/resources/schemas/message.avsc
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<canonicalize>true</canonicalize>
</artifact>
</artifacts>
</configuration>
</execution>
Expand All @@ -218,7 +251,7 @@
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>1.0.2</version>
<version>1.3.0</version>
</plugin>
</plugins>
</build>
Expand All @@ -232,7 +265,7 @@
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>1.0.2</version>
<version>1.3.0</version>
</plugin>
</plugins>
</build>
Expand All @@ -250,7 +283,7 @@
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -262,9 +295,10 @@
<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>
org.jboss.logmanager.LogManager
</java.util.logging.manager>
<!--<maven.home>${maven.home}</maven.home>-->
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
Expand Down
4 changes: 2 additions & 2 deletions src/main/apicurio/operator/subscription-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: apicurio-registry
namespace: amq-streams-demo
namespace: operators
spec:
channel: alpha
channel: 2.x
name: apicurio-registry
source: operatorhubio-catalog
sourceNamespace: olm
2 changes: 1 addition & 1 deletion src/main/apicurio/operator/subscription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: apicurio-registry
namespace: amq-streams-demo
spec:
channel: alpha
channel: 2.x
installPlanApproval: Automatic
name: apicurio-registry
source: community-operators
Expand Down
12 changes: 4 additions & 8 deletions src/main/apicurio/service-registry.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
apiVersion: apicur.io/v1alpha1
apiVersion: registry.apicur.io/v1
kind: ApicurioRegistry
metadata:
name: service-registry
spec:
configuration:
logLevel: INFO
persistence: "streams"
streams:
applicationId: "service-registry"
persistence: "kafkasql"
kafkasql:
bootstrapServers: "my-kafka-kafka-bootstrap:9093"
security:
scram:
mechanism: SCRAM-SHA-512
user: service-registry-scram
passwordSecretName: service-registry-scram
truststoreSecretName: my-kafka-cluster-ca-cert
# tls:
# keystoreSecretName: service-registry-tls
# truststoreSecretName: my-kafka-cluster-ca-cert
ui:
readOnly: false
logLevel: INFO
deployment:
replicas: 1
11 changes: 11 additions & 0 deletions src/main/apicurio/topics/kafkasql-journal-topic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaTopic
metadata:
labels:
strimzi.io/cluster: my-kafka
name: kafkasql-journal
spec:
partitions: 1
replicas: 1
config:
cleanup.policy: compact
13 changes: 0 additions & 13 deletions src/main/apicurio/topics/kafkatopic-global-id-topic.yml

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/apicurio/topics/kafkatopic-storage-topic.yml

This file was deleted.

54 changes: 54 additions & 0 deletions src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the container image run:
#
# ./mvnw package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/kafka-clients-quarkus-sample .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/kafka-clients-quarkus-sample-jvm
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/kafka-clients-quarkus-sample-jvm
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3

ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]
Loading

0 comments on commit 6ee4987

Please sign in to comment.