// Module included in the following assemblies:
//
// assembly-using-kafka-connect-with-plugins.adoc
// assembly-deployment-configuration-kafka-connect-s2i.adoc

[id='using-openshift-s2i-create-image-{context}']
= Creating a container image using {OpenShiftName} builds and Source-to-Image

You can use {OpenShiftName} link:https://docs.openshift.org/3.9/dev_guide/builds/index.html[builds^] and the  link:https://docs.openshift.org/3.9/creating_images/s2i.html#creating-images-s2i[Source-to-Image (S2I)^] framework to create new container images. An OpenShift build takes a builder image with S2I support, together with source code and binaries provided by the user, and uses them to build a new container image. Once built, container images are stored in {OpenShiftName}'s local container image repository and are available for use in deployments.

A Kafka Connect builder image with S2I support is provided by {ProductName} on the {DockerRepository} as `{DockerKafkaConnectS2I}`. This S2I image takes your binaries (with plug-ins and connectors) and stores them in the `/tmp/kafka-plugins/s2i` directory. It creates a new Kafka Connect image from this directory, which can then be used with the Kafka Connect deployment. When started using the enhanced image, Kafka Connect loads any third-party plug-ins from the `/tmp/kafka-plugins/s2i` directory.

.Procedure

. On the command line, use the `oc apply` command to create and deploy a Kafka Connect S2I cluster:
+
[source,subs="+quotes"]
----
oc apply -f examples/kafka-connect/kafka-connect-s2i.yaml
----

. Create a directory with Kafka Connect plug-ins:
+
[source,subs="+quotes"]
----
$ tree ./_my-plugins_/
./_my-plugins_/
├── debezium-connector-mongodb
│   ├── bson-3.4.2.jar
│   ├── CHANGELOG.md
│   ├── CONTRIBUTE.md
│   ├── COPYRIGHT.txt
│   ├── debezium-connector-mongodb-0.7.1.jar
│   ├── debezium-core-0.7.1.jar
│   ├── LICENSE.txt
│   ├── mongodb-driver-3.4.2.jar
│   ├── mongodb-driver-core-3.4.2.jar
│   └── README.md
├── debezium-connector-mysql
│   ├── CHANGELOG.md
│   ├── CONTRIBUTE.md
│   ├── COPYRIGHT.txt
│   ├── debezium-connector-mysql-0.7.1.jar
│   ├── debezium-core-0.7.1.jar
│   ├── LICENSE.txt
│   ├── mysql-binlog-connector-java-0.13.0.jar
│   ├── mysql-connector-java-5.1.40.jar
│   ├── README.md
│   └── wkb-1.0.2.jar
└── debezium-connector-postgres
    ├── CHANGELOG.md
    ├── CONTRIBUTE.md
    ├── COPYRIGHT.txt
    ├── debezium-connector-postgres-0.7.1.jar
    ├── debezium-core-0.7.1.jar
    ├── LICENSE.txt
    ├── postgresql-42.0.0.jar
    ├── protobuf-java-2.6.1.jar
    └── README.md
----

. Use the `oc start-build` command to start a new build of the image using the prepared directory:
+
[source,subs="+quotes"]
oc start-build _my-connect-cluster-connect_ --from-dir ./_my-plugins_/
+
NOTE: The name of the build is the same as the name of the deployed Kafka Connect cluster.

. Once the build has finished, the new image is used automatically by the Kafka Connect deployment.
