Skip to content

Commit

Permalink
⬆️ Upgrade to Quarkus 2.5.1 and beyond (#4)
Browse files Browse the repository at this point in the history
* ⬆️ Upgraded to Apicurio v2.0.0 Operator
* ⬆️ Upgraded to Strimzi 0.26.0 and Kafka 2.8.1
* 🔧 Moved to standard web port (8080)
* ⬆️ Upgraded Quarkus 2.4.2, Apicurio 2.1.2
* 📝 How to deploy to OpenShift and Kubernetes
* ⬆️ Quarkus, Apicurio and beyond
* 📝 References and instructions
  • Loading branch information
rmarting authored Dec 9, 2021
1 parent a6eef4f commit db9a736
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 53 deletions.
64 changes: 29 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
## :rocket: :sparkles: :rotating_light: QUARKUS EDITION :rotating_light: :sparkles: :rocket:

This repo is a fork of the original one based in [Spring Boot](https://github.com/rmarting/kafka-clients-sb-sample)
but refactored to be a full-compliant [Quarkus](https://quarkus.io/) application. This repo is described in
[Integrating Quarkus and Apicurio Service Registry](https://blog.jromanmartin.io/2020/12/18/integrating-quarkus-and-apicurio-service-registry.html)
blog post.
but refactored to be a full-compliant [Quarkus](https://quarkus.io/) application.

This repo is also the base for the following blog posts:

* [Lessons learned migrating Spring Boot to Quarkus](https://blog.jromanmartin.io/2021/12/03/lessons-learned-migrating-spring-boot-quarkus.html)
* [Integrating Quarkus and Apicurio Service Registry](https://blog.jromanmartin.io/2020/12/18/integrating-quarkus-and-apicurio-service-registry.html)

The following components were refactored from Spring Boot to Quarkus Extensions:

Expand All @@ -21,8 +24,8 @@ The following components were refactored from Spring Boot to Quarkus Extensions:
This new version is really fast (less than 2 seconds) ... like a :rocket:

```text
Jun 30, 2021 9:57:02 PM io.quarkus.bootstrap.runner.Timing printStartupTime
INFO: kafka-clients-quarkus-sample 2.0.0-SNAPSHOT on JVM (powered by Quarkus 2.0.0.Final) started in 1.755s. Listening on: http://0.0.0.0:8181
Dec 09, 2021 2:56:17 PM io.quarkus.bootstrap.runner.Timing printStartupTime
INFO: kafka-clients-quarkus-sample 2.5.1-SNAPSHOT on JVM (powered by Quarkus 2.5.1.Final) started in 1.301s. Listening on: http://0.0.0.0:8080
```

## :rocket: :sparkles: :rotating_light: QUARKUS EDITION :rotating_light: :sparkles: :rocket:
Expand Down Expand Up @@ -59,11 +62,11 @@ This repo was tested with the following latest versions of Red Hat CodeReady Con

```shell
❯ crc version
CodeReady Containers version: 1.28.0+08de64bd
OpenShift version: 4.7.13 (embedded in executable)
CodeReady Containers version: 1.36.0+c0f4e0d3
OpenShift version: 4.9.8 (embedded in executable)
❯ minikube version
minikube version: v1.21.0
commit: 76d74191d82c47883dc7e1319ef7cebd3e00ee11
minikube version: v1.24.0
commit: 76b94fb3c4e8ac5062daf70d60cf03ddcc0a741b
```

> Note: Whatever the platform you are using (Kubernetes or OpenShift), you could use the
Expand Down Expand Up @@ -122,18 +125,9 @@ To start up your local Kubernetes cluster:
❯ minikube start
❯ minikube addons enable ingress
❯ minikube addons enable registry
❯ minikube addons enable olm
```

To install the OLM v0.18.2 in Kubernetes, execute the following commands:

```shell
❯ kubectl apply -f "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.2/crds.yaml"
❯ kubectl apply -f "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.2/olm.yaml"
```

> Note: There is an addon in minikube to install OLM, however at the moment of writing this
> repo, the latest version available not include the latest version of the operators.
### Deploying Strimzi and Apicurio Operators

> **NOTE**: Only *cluster-admin* users could deploy Kubernetes Operators. This section must
Expand Down Expand Up @@ -175,20 +169,20 @@ You could check that operators are successfully registered with the following co
❯ kubectl get csv
NAME DISPLAY VERSION REPLACES PHASE
apicurio-registry-operator.v1.0.0-v2.0.0.final Apicurio Registry Operator 1.0.0-v2.0.0.final Succeeded
strimzi-cluster-operator.v0.24.0 Strimzi 0.23.0 strimzi-cluster-operator.v0.23.0 Succeeded
strimzi-cluster-operator.v0.26.0 Strimzi 0.26.0 strimzi-cluster-operator.v0.25.0 Succeeded
```

or verify the pods are running:

```shell
❯ kubectl get pod
NAME READY STATUS RESTARTS AGE
apicurio-registry-operator-5b885fb47c-5dgw5 1/1 Running 0 2m36s
strimzi-cluster-operator-v0.24.0-888d55ccb-q8cgl 1/1 Running 0 2m43s
apicurio-registry-operator-6bbddcff85-kx98g 1/1 Running 0 49s
strimzi-cluster-operator-v0.26.0-cf854dccb-wrsrh 1/1 Running 0 52s
```

For more information about how to install Operators using the CLI command, please review this [article](
https://docs.openshift.com/container-platform/4.7/operators/admin/olm-adding-operators-to-cluster.html#olm-installing-operator-from-operatorhub-using-cli_olm-adding-operators-to-a-cluster)
https://docs.openshift.com/container-platform/4.9/operators/admin/olm-adding-operators-to-cluster.html#olm-installing-operator-from-operatorhub-using-cli_olm-adding-operators-to-a-cluster)

### Deploying Kafka

Expand Down Expand Up @@ -228,12 +222,12 @@ After some minutes Kafka Cluster will be deployed:

```shell
❯ kubectl get pod
NAME READY STATUS RESTARTS AGE
apicurio-registry-operator-cbf6fcf57-d6shn 1/1 Running 0 4m32s
my-kafka-entity-operator-6d9596458b-rl5w9 3/3 Running 0 59s
my-kafka-kafka-0 2/2 Running 0 2m6s
my-kafka-zookeeper-0 1/1 Running 0 3m20s
strimzi-cluster-operator-v0.19.0-7555cff6d9-vlgwp 1/1 Running 0 4m37s
NAME READY STATUS RESTARTS AGE
apicurio-registry-operator-6bbddcff85-kx98g 1/1 Running 0 4m6s
my-kafka-entity-operator-6495999c7f-6fls8 3/3 Running 0 35s
my-kafka-kafka-0 1/1 Running 0 107s
my-kafka-zookeeper-0 1/1 Running 0 2m59s
strimzi-cluster-operator-v0.26.0-cf854dccb-wrsrh 1/1 Running 0 4m9s
```

### Service Registry
Expand Down Expand Up @@ -269,8 +263,8 @@ In OpenShift, we only need to check the ```host``` attribute from the OpenShift

```shell
❯ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
service-registry-ingress-48txm service-registry.amq-streams-demo.apps-crc.testing / service-registry-service <all> None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
service-registry-ingress-pqgfv service-registry.amq-streams-demo.router-default.apps-crc.testing / service-registry-service <all> None
```

While few minutes until your Service Registry has deployed.
Expand Down Expand Up @@ -347,11 +341,11 @@ spec:
There is a deployment definition in [deployment.yml](./src/main/jkube/deployment.yml) file. This file will be used
by JKube to deploy our application in Kubernetes or OpenShift.
* **Service Registry API Endpoint**: Avro Serde classes need to communicate with the Service Registry API to check and
* **Service Registry API Endpoint**: Avro SerDe classes need to communicate with the Service Registry API to check and
validate the schemas.
```text
apicurio.registry.url = http://service-registry.amq-streams-demo.apps-crc.testing/apis/registry/v2
apicurio.registry.url = http://service-registry-service:8080/apis/registry/v2
```

To build the application:
Expand Down Expand Up @@ -452,7 +446,7 @@ Simple Sample:
}
```

With Minikube:
With minikube:

```shell script
❯ curl $(minikube ip):$(kubectl get svc kafka-clients-quarkus-sample -o jsonpath='{.spec.ports[].nodePort}')/producer/kafka/messages \
Expand Down Expand Up @@ -497,7 +491,7 @@ Simple Sample:
}
```

With Minikube:
With minikube:

```shell script
❯ curl $(minikube ip):$(kubectl get svc kafka-clients-quarkus-sample -o jsonpath='{.spec.ports[].nodePort}')"/consumer/kafka/messages?commit=true&partition=0" | jq
Expand Down
Binary file modified img/apicurio-registry-artifacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 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>2.0.0-SNAPSHOT</version>
<version>2.5.1-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencyManagement>
Expand All @@ -27,19 +27,17 @@
<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.7.0</kafka-clients.version>
<kafka-clients.version>2.8.0</kafka-clients.version>
<!-- Avro -->
<avro.version>1.10.2</avro.version>
<!-- Apicurio Registry -->
<apicurio.version>2.0.1.Final</apicurio.version>
<apicurio.version>2.1.4.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>
<apicurio.registry.url>http://service-registry.amq-streams-demo.router-default.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>2.0.1.Final</quarkus.platform.version>
<quarkus.platform.version>2.5.1.Final</quarkus.platform.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -255,7 +253,7 @@
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>1.3.0</version>
<version>1.5.1</version>
</plugin>
</plugins>
</build>
Expand All @@ -264,12 +262,15 @@
<!-- Kubernetes Deployment -->
<profile>
<id>kubernetes</id>
<properties>
<jkube.enricher.jkube-service.type>NodePort</jkube.enricher.jkube-service.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>1.3.0</version>
<version>1.5.1</version>
</plugin>
</plugins>
</build>
Expand Down
1 change: 1 addition & 0 deletions src/main/apicurio/operator/subscription-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ spec:
name: apicurio-registry
source: operatorhubio-catalog
sourceNamespace: olm
startingCSV: apicurio-registry-operator.v1.0.0-v2.0.0.final
1 change: 1 addition & 0 deletions src/main/apicurio/operator/subscription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ spec:
name: apicurio-registry
source: community-operators
sourceNamespace: openshift-marketplace
startingCSV: apicurio-registry-operator.v1.0.0-v2.0.0.final
6 changes: 3 additions & 3 deletions src/main/jkube/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ spec:
key: password
name: application
ports:
- containerPort: 8181
- containerPort: 8080
name: http
protocol: TCP
livenessProbe:
failureThreshold: 3
httpGet:
path: /q/health/live
port: 8181
port: 8080
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
Expand All @@ -36,7 +36,7 @@ spec:
failureThreshold: 3
httpGet:
path: /q/health/ready
port: 8181
port: 8080
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ kafka.sasl.jaas.config = org.apache.kafka.common.security.scram.ScramLoginModule
#
# Quarkus Properties
#
quarkus.http.port=8181
quarkus.http.port=8080

# Configure the Kafka source (we read from it)
mp.messaging.incoming.messages.connector=smallrye-kafka
Expand Down
4 changes: 2 additions & 2 deletions src/main/strimzi/kafka/kafka-ha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
name: my-kafka
spec:
kafka:
version: 2.7.0
version: 2.8.1
config:
# Log message format
log.message.format.version: "2.7"
log.message.format.version: "2.8"
# default replication factors for automatically created topics
default.replication.factor: 3
# The default number of log partitions per topic
Expand Down
4 changes: 2 additions & 2 deletions src/main/strimzi/kafka/kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
name: my-kafka
spec:
kafka:
version: 2.7.0
version: 2.8.1
config:
# Log message format
log.message.format.version: "2.7"
log.message.format.version: "2.8"
# default replication factors for automatically created topics
default.replication.factor: 1
# The default number of log partitions per topic
Expand Down
1 change: 1 addition & 0 deletions src/main/strimzi/operator/subscription-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ spec:
name: strimzi-kafka-operator
source: operatorhubio-catalog
sourceNamespace: olm
startingCSV: strimzi-cluster-operator.v0.26.0
3 changes: 2 additions & 1 deletion src/main/strimzi/operator/subscription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ spec:
installPlanApproval: Automatic
name: strimzi-kafka-operator
source: community-operators
sourceNamespace: openshift-marketplace
sourceNamespace: openshift-marketplace
startingCSV: strimzi-cluster-operator.v0.26.0

0 comments on commit db9a736

Please sign in to comment.