From db1a62334bee714a694b71e95d184bdc02d7f16f Mon Sep 17 00:00:00 2001 From: Krystof Stekovic Date: Tue, 11 Jun 2024 15:51:12 +0200 Subject: [PATCH 1/2] [WFLY-19359] define kafka yaml file for OpenShift and update the README. --- .../overridable-functions.sh | 114 ++++-------------- .../README-source.adoc | 3 + .../charts/amq-operator-on-openshift.yaml | 13 ++ .../charts/kafka-on-openshift.yaml | 35 ++++++ .../helm-install-prerequisites.adoc | 65 ++++------ 5 files changed, 95 insertions(+), 135 deletions(-) create mode 100644 microprofile-reactive-messaging-kafka/charts/amq-operator-on-openshift.yaml create mode 100644 microprofile-reactive-messaging-kafka/charts/kafka-on-openshift.yaml diff --git a/.ci/openshift-ci/build-root/scripts/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh b/.ci/openshift-ci/build-root/scripts/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh index 11b64461e6..35f55c5d2e 100644 --- a/.ci/openshift-ci/build-root/scripts/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh +++ b/.ci/openshift-ci/build-root/scripts/qs-overrides/microprofile-reactive-messaging-kafka/overridable-functions.sh @@ -26,103 +26,36 @@ function applicationName() { # 1 - application name function installPrerequisites() { - application="${1}" - echo "Creating amq-streams-operator-group" + maxWaitingTimeInSeconds=900 # 15 minutes - oc apply -f - < - # We do this check first because it takes a while to appear - oc get pods -l app.kubernetes.io/instance='my-cluster',app.kubernetes.io/name='entity-operator' | grep "my-cluster-entity-operator" || continue - - # Wait 10 seconds for all pods to come up, and renter the loop if not - oc wait pod -l app.kubernetes.io/instance='my-cluster' --for=condition=Ready --timeout=10s || continue - - # If we got here, everything is up, so we can proceed + sleep 5 + echo "Checking if \"my-cluster-entity-operator\" pod is ready" + # Check the entity operator exists. And 1/1 instance is ready to use + oc get pod | grep "my-cluster-entity-operator" | grep "1/1" || continue + echo "The AMQ stream instance ready!" break done } @@ -135,10 +68,7 @@ EOF # 1 - application name function cleanPrerequisites() { - # TODO There are a few topics created that need cleaning up - - oc delete kafka my-cluster - oc delete subscription amq-streams-subscription - oc delete operatorgroup amq-streams-operator-group - oc delete deployment amq-streams-cluster-operator-v2.5.0-1 + echo "Deleting all AMQ streams resources" + oc delete -f ./charts/amq-operator-on-openshift.yaml --wait --timeout=10m0s + oc delete -f ./charts/kafka-on-openshift.yaml --wait --timeout=10m0s } diff --git a/microprofile-reactive-messaging-kafka/README-source.adoc b/microprofile-reactive-messaging-kafka/README-source.adoc index af58276023..07e5161ca6 100644 --- a/microprofile-reactive-messaging-kafka/README-source.adoc +++ b/microprofile-reactive-messaging-kafka/README-source.adoc @@ -987,6 +987,9 @@ bin/kafka-topics.sh --create --topic testing --bootstrap-server localhost:9092 // OpenShift include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] +---- +$ oc delete -f ./charts/kafka-on-openshift.yaml --wait --timeout=10m0s +---- == Conclusion diff --git a/microprofile-reactive-messaging-kafka/charts/amq-operator-on-openshift.yaml b/microprofile-reactive-messaging-kafka/charts/amq-operator-on-openshift.yaml new file mode 100644 index 0000000000..74e8d9c859 --- /dev/null +++ b/microprofile-reactive-messaging-kafka/charts/amq-operator-on-openshift.yaml @@ -0,0 +1,13 @@ +# Subscribe the Red Hat Streams for Apache Kafka operator +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + generation: 1 + name: amq-streams + namespace: openshift-operators +spec: + channel: stable + installPlanApproval: Automatic + name: amq-streams + source: redhat-operators + sourceNamespace: openshift-marketplace diff --git a/microprofile-reactive-messaging-kafka/charts/kafka-on-openshift.yaml b/microprofile-reactive-messaging-kafka/charts/kafka-on-openshift.yaml new file mode 100644 index 0000000000..7e58e9984a --- /dev/null +++ b/microprofile-reactive-messaging-kafka/charts/kafka-on-openshift.yaml @@ -0,0 +1,35 @@ +# This is the YAML needed to install Kafka provided by Strimzi on OpenShift. + +# create a Kafka Stream instance +apiVersion: kafka.strimzi.io/v1beta2 +kind: Kafka +metadata: + name: my-cluster +spec: + kafka: + replicas: 3 + listeners: + - name: plain + port: 9092 + type: internal + tls: false + storage: + type: ephemeral + zookeeper: + replicas: 3 + storage: + type: ephemeral + entityOperator: + topicOperator: {} + +--- +# create a topic in Kafka Stream instance +apiVersion: kafka.strimzi.io/v1beta2 +kind: KafkaTopic +metadata: + name: testing +labels: + strimzi.io/cluster: my-cluster +spec: + partitions: 3 + replicas: 3 \ No newline at end of file diff --git a/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc b/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc index 2f4263bb3f..f6044895d1 100644 --- a/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc +++ b/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc @@ -1,67 +1,46 @@ === Install AMQ Streams on OpenShift The functionality of this quickstart depends on a running instance of the -https://access.redhat.com/products/red-hat-amq#streams[AMQ Streams] Operator. AMQ Streams is a Red Hat project based on Apache Kafka. To deploy AMQ Streams in the Openshift environment: +https://access.redhat.com/products/red-hat-amq#streams[AMQ Streams] Operator. AMQ Streams is a Red Hat project based +on Apache Kafka. To deploy AMQ Streams in the Openshift environment: . Log in into the Openshift console as `kubeadmin` user (or any cluster administrator). -. Navigate to `Operators` -> `OperatorHub`. -. Search for `AMQ Streams` - click on the 'AMQ Streams' operator. -+ +. Install the `Red Hat Streams for Apache Kafka` operator +. Create an instance of `Red Hat Streams for Apache Kafka` +. Create a topic in the `Red Hat Streams for Apache Kafka` + Install it with the default values and wait for the message telling you it has been installed and is ready for use. -. In your terminal, run the following command to set up a Kafka cluster called `my-cluster` in your project: -+ + +In your terminal, run the following command to subscribe the `Red Hat Streams for Apache Kafka` operator. [options="nowrap",subs="+attributes"] ---- -$ oc apply -f - < Date: Mon, 17 Jun 2024 14:06:58 +0200 Subject: [PATCH 2/2] [WFLY-19359] define kafka yaml file for OpenShift and update the README. --- microprofile-reactive-messaging-kafka/README-source.adoc | 1 + .../helm-install-prerequisites.adoc | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/microprofile-reactive-messaging-kafka/README-source.adoc b/microprofile-reactive-messaging-kafka/README-source.adoc index 07e5161ca6..072caf4af0 100644 --- a/microprofile-reactive-messaging-kafka/README-source.adoc +++ b/microprofile-reactive-messaging-kafka/README-source.adoc @@ -989,6 +989,7 @@ bin/kafka-topics.sh --create --topic testing --bootstrap-server localhost:9092 include::../shared-doc/build-and-run-the-quickstart-with-openshift.adoc[leveloffset=+1] ---- $ oc delete -f ./charts/kafka-on-openshift.yaml --wait --timeout=10m0s +$ oc delete -f ./charts/amq-operator-on-openshift.yaml --wait --timeout=10m0s ---- == Conclusion diff --git a/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc b/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc index f6044895d1..95d2dad9d2 100644 --- a/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc +++ b/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc @@ -1,8 +1,7 @@ === Install AMQ Streams on OpenShift The functionality of this quickstart depends on a running instance of the -https://access.redhat.com/products/red-hat-amq#streams[AMQ Streams] Operator. AMQ Streams is a Red Hat project based -on Apache Kafka. To deploy AMQ Streams in the Openshift environment: +https://access.redhat.com/products/red-hat-amq#streams[AMQ Streams] Operator. AMQ Streams is a Red Hat project based on Apache Kafka. To deploy AMQ Streams in the Openshift environment: . Log in into the Openshift console as `kubeadmin` user (or any cluster administrator). . Install the `Red Hat Streams for Apache Kafka` operator @@ -33,8 +32,7 @@ Then you can set up a Kafka cluster called `my-cluster` with topic `testing` in $ oc apply -f ./charts/kafka-on-openshift.yaml --wait --timeout=10m0s ---- -Although the above commands will return pretty immediately, your AMQ Streams instance will not be available until its -entity operator is up and running. The name of the pod will be of the format `my-cluster-entity-operator-xxxxxxxxx-yyyyy`. +Although the above commands will return pretty immediately, your AMQ Streams instance will not be available until its entity operator is up and running. The name of the pod will be of the format `my-cluster-entity-operator-xxxxxxxxx-yyyyy`. To be on the safe side, wait until this pod is ready, as shown in this example: [options="nowrap",subs="+attributes"]