// Module included in the following assemblies:
//
// assembly-deploy-kafka-connect-with-plugins.adoc

[id='creating-new-image-using-kafka-connect-build-{context}']
= Building a new container image with connector plugins automatically

[role="_abstract"]
Configure Kafka Connect so that Strimzi automatically builds a new container image with additional connectors.
You define the connector plugins using the `.spec.build.plugins` property of the `KafkaConnect` custom resource.
Strimzi will automatically download and add the connector plugins into a new container image.
The container is pushed into the container repository specified in `.spec.build.output` and automatically used in the Kafka Connect deployment.

.Prerequisites

* xref:deploying-cluster-operator-str[The Cluster Operator must be deployed.]
* A container registry.

You need to provide your own container registry where images can be pushed to, stored, and pulled from.
Strimzi supports private container registries as well as public registries such as link:https://quay.io/[Quay^] or link:https://hub.docker.com//[Docker Hub^].

.Procedure

. Configure the `KafkaConnect` custom resource by specifying the container registry in `.spec.build.output`, and additional connectors in `.spec.build.plugins`:
+
[source,yaml,subs=attributes+,options="nowrap"]
----
apiVersion: {KafkaConnectApiVersion}
kind: KafkaConnect
metadata:
  name: my-connect-cluster
spec: # <1>
  #...
  build:
    output: # <2>
      type: docker
      image: my-registry.io/my-org/my-connect-cluster:latest
      pushSecret: my-registry-credentials
    plugins: # <3>
      - name: debezium-postgres-connector
        artifacts:
          - type: tgz
            url: https://repo1.maven.org/maven2/io/debezium/debezium-connector-postgres/2.1.3.Final/debezium-connector-postgres-2.1.3.Final-plugin.tar.gz
            sha512sum: c4ddc97846de561755dc0b021a62aba656098829c70eb3ade3b817ce06d852ca12ae50c0281cc791a5a131cb7fc21fb15f4b8ee76c6cae5dd07f9c11cb7c6e79
      - name: camel-telegram
        artifacts:
          - type: tgz
            url: https://repo.maven.apache.org/maven2/org/apache/camel/kafkaconnector/camel-telegram-kafka-connector/0.11.5/camel-telegram-kafka-connector-0.11.5-package.tar.gz
            sha512sum: d6d9f45e0d1dbfcc9f6d1c7ca2046168c764389c78bc4b867dab32d24f710bb74ccf2a007d7d7a8af2dfca09d9a52ccbc2831fc715c195a3634cca055185bd91
  #...
----
<1> link:{BookURLConfiguring}#type-KafkaConnectSpec-reference[The specification for the Kafka Connect cluster^].
<2> (Required) Configuration of the container registry where new images are pushed.
<3> (Required) List of connector plugins and their artifacts to add to the new container image. Each plugin must be configured with at least one `artifact`.

. Create or update the resource:
+
[source,subs="+quotes"]
----
$ kubectl apply -f <kafka_connect_configuration_file>
----

. Wait for the new container image to build, and for the Kafka Connect cluster to be deployed.

. Use the Kafka Connect REST API or `KafkaConnector` custom resources to use the connector plugins you added.

[role="_additional-resources"]
.Additional resources

* link:{BookURLConfiguring}#type-Build-reference[Kafka Connect `Build` schema reference^]
