// Module included in the following assemblies:
//
// deploying/assembly_deploy-kafka-connect-with-plugins.adoc

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

This procedure shows how to use OpenShift {docs-okd} and the {docs-okd-s2i} framework to create a new container image.

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 OpenShift's local container image repository and are available for use in deployments.

A Kafka Connect builder image with S2I support is provided on the {DockerRepository} as part of the `{DockerKafkaConnectS2I}` image.
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,shell,subs="+quotes"]
----
oc apply -f examples/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,shell,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.

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