From 6e033d53dc54d16b8925524c65c6ef8026333770 Mon Sep 17 00:00:00 2001 From: Krystof Stekovic Date: Tue, 11 Jun 2024 15:51:12 +0200 Subject: [PATCH] [WFLY-19359] define kafka yaml file for OpenShift and update the README. --- .../overridable-functions.sh | 116 ++++-------------- .../README-source.adoc | 3 + .../charts/amq-operator-on-openshift.yaml | 13 ++ .../charts/kafka-on-openshift.yaml | 35 ++++++ .../helm-install-prerequisites.adoc | 51 +------- 5 files changed, 80 insertions(+), 138 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..bef9d7735f 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 1 + 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..403ef04fba 100644 --- a/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc +++ b/microprofile-reactive-messaging-kafka/helm-install-prerequisites.adoc @@ -4,56 +4,17 @@ 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: . 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 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: -+ -[options="nowrap",subs="+attributes"] ----- -$ oc apply -f - <