<commit_before>[id="deploying-debezium-on-openshift"]
= Deploying {prodname} on OpenShift

:linkattrs:
:icons: font
:toc:
:toc-placement: macro

toc::[]

This procedure is for setting up {prodname} connectors on Red Hat's link:https://www.openshift.com/[OpenShift] container platform. These instructions have been tested with the two most recent releases of OpenShift. 

To get started more quickly, try the link:https://learn.openshift.com/middleware/debezium-getting-started/[{prodname} online learning scenario].
It starts an OpenShift cluster just for you, which lets you start using {prodname} in your browser within a few minutes.

== {prodname} Deployment

To set up Kafka and Kafka Connect on OpenShift, use the set of images that are provided by the link:https://strimzi.io/[Strimzi] project. These images offer "Kafka as a Service" by providing enterprise grade configuration files and images that bring Kafka to OpenShift.

.Prerequisites

* The OpenShift command line interface (`oc`) is installed.

.Procedure

. In your OpenShift project, enter the following commands to install the operators and templates for the Kafka broker and Kafka Connect:
+
[source,shell,subs="attributes",options="nowrap"]
----
export STRIMZI_VERSION={strimzi-version}
git clone -b $STRIMZI_VERSION https://github.com/strimzi/strimzi-kafka-operator
cd strimzi-kafka-operator

# Switch to an admin user to create security objects as part of installation:
oc login -u system:admin
oc create -f install/cluster-operator && oc create -f examples/templates/cluster-operator
----

. Deploy a Kafka broker cluster and a Kafka Connect cluster and then create a Kafka Connect image with the {prodname} connectors installed:
+
[source,shell,subs="attributes",options="nowrap"]
----
# Deploy an ephemeral single instance Kafka broker:
oc process strimzi-ephemeral -p CLUSTER_NAME=broker -p ZOOKEEPER_NODE_COUNT=1 -p KAFKA_NODE_COUNT=1 -p KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 -p KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 | oc apply -f -

# Deploy a single instance of Kafka Connect with no plug-in installed:
oc process strimzi-connect-s2i -p CLUSTER_NAME=debezium -p KAFKA_CONNECT_BOOTSTRAP_SERVERS=broker-kafka-bootstrap:9092 -p KAFKA_CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR=1 -p KAFKA_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR=1 -p KAFKA_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR=1 -p KAFKA_CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE=false -p KAFKA_CONNECT_KEY_CONVERTER_SCHEMAS_ENABLE=false | oc apply -f -

# Build a Debezium image
export DEBEZIUM_VERSION={debezium-version}
mkdir -p plugins && cd plugins && \
for PLUGIN in {mongodb,mysql,postgres,sqlserver}; do \
    curl http://central.maven.org/maven2/io/debezium/debezium-connector-$PLUGIN/$DEBEZIUM_VERSION/debezium-connector-$PLUGIN-$DEBEZIUM_VERSION-plugin.tar.gz | tar xz; \
done && \
oc start-build debezium-connect --from-dir=. --follow && \
cd .. && rm -rf plugins
----
+
After a while all parts should be up and running:
+
[source%nowrap,bash]
----
oc get pods

NAME                                       READY     STATUS        RESTARTS   AGE
broker-entity-operator-5fb7bc8b9b-r86nz    3/3       Running       1          4m
broker-kafka-0                             2/2       Running       0          4m
broker-zookeeper-0                         2/2       Running       0          5m
debezium-connect-3-4sdjr                   1/1       Running       0          1m
strimzi-cluster-operator-d77476b8f-rblqf   1/1       Running       0          5m<commit_msg>DBZ-1908 Replaced dockerfile and EXPORT section by using Strimzi blog procedure<commit_after>[id="deploying-debezium-on-openshift"]
= Deploying {prodname} on OpenShift

:linkattrs:
:icons: font
:toc:
:toc-placement: macro

toc::[]

This procedure is for setting up {prodname} connectors on Red Hat's link:https://www.openshift.com/[OpenShift] container platform. These instructions have been tested with the two most recent releases of OpenShift. 

To get started more quickly, try the link:https://learn.openshift.com/middleware/debezium-getting-started/[{prodname} online learning scenario].
It starts an OpenShift cluster just for you, which lets you start using {prodname} in your browser within a few minutes.

== {prodname} Deployment

To set up Kafka and Kafka Connect on OpenShift, use the set of images that are provided by the link:https://strimzi.io/[Strimzi] project. These images offer "Kafka as a Service" by providing enterprise grade configuration files and images that bring Kafka to OpenShift.

.Prerequisites

* The OpenShift command line interface (`oc`) is installed.
* Docker is installed. 

.Procedure

. In your OpenShift project, enter the following commands to install the operators and templates for the Kafka broker and Kafka Connect:
+
[source,shell,subs="attributes",options="nowrap"]
----
export STRIMZI_VERSION={strimzi-version}
git clone -b $STRIMZI_VERSION https://github.com/strimzi/strimzi-kafka-operator
cd strimzi-kafka-operator

# Switch to an admin user to create security objects as part of installation:
oc login -u system:admin
oc create -f install/cluster-operator && oc create -f examples/templates/cluster-operator
----

. Deploy a Kafka broker cluster:
+
[source,shell,subs="attributes",options="nowrap"]
----
# Deploy an ephemeral single instance Kafka broker:
oc process strimzi-ephemeral -p CLUSTER_NAME=broker -p ZOOKEEPER_NODE_COUNT=1 -p KAFKA_NODE_COUNT=1 -p KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 -p KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 | oc apply -f -
----

. Create a Kafka Connect image with the {prodname} connectors installed:

.. Download and extract the archive for each {prodname} connector you want to run. For example: 
+
[source,options="nowrap"]
----
curl https://repo1.maven.org/maven2/io/debezium/debezium-connector-mysql/1.1.0.Final/debezium-connector-mysql-1.1.0.Final-plugin.tar.gz tar xvz`
----

.. Create a `Dockerfile` that uses a Strimzi Kafka image as the base image. The following example creates a `plugins/debezium` directory, which would contain a directory for each {prodname} connector that you want to run. To run more than one {prodname} connector, insert a `COPY` line for each connector. 
+
[subs=+macros]
----
FROM strimzi/kafka:0.19.0-kafka-2.5.0
USER root:root
RUN mkdir -p /opt/kafka/plugins/debezium
COPY ./debezium-connector-mysql/ /opt/kafka/plugins/debezium/
USER 1001
----
+
Before Kafka Connect starts running the connector, Kafka Connect loads any third-party plug-ins that are in the `/opt/kafka/plugins` directory.

.. Build a Debezium image from your Dockerfile and push it to Docker Hub by executing the following commands. Replace `debezium-community` with the name of your Docker Hub organization. 
+
----
export DOCKER_ORG=debezium-community
docker build . -t ${DOCKER_ORG}/connect-debezium
docker push ${DOCKER_ORG}/connect-debezium
----
+
After a while all parts should be up and running:
+
[source%nowrap,bash]
----
oc get pods

NAME                                       READY     STATUS        RESTARTS   AGE
broker-entity-operator-5fb7bc8b9b-r86nz    3/3       Running       1          4m
broker-kafka-0                             2/2       Running       0          4m
broker-zookeeper-0                         2/2       Running       0          5m
debezium-connect-3-4sdjr                   1/1       Running       0          1m
strimzi-cluster-operator-d77476b8f-rblqf   1/1       Running       0          5m
{'fraction_non_alphanumeric': 0.0880300590445518, 'fraction_numerical': 0.015029522275899088, 'mean_word_length': 3.4682254196642686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5104853', 'n_tokens_mistral': 2407, 'n_tokens_neox': 2313, 'n_words': 744}