Add Connectors or Software for Confluent Platform
This page describes how you can extend the Kafka Connect client, including steps to create a Docker image containing local connectors, to add new software to an image, and to create images with your own Kafka Connect plugins.
Note
Enterprise support is not provided for the Confluent Community licensed distributions of Kafka Connect workers (CCS, cp-kafka-connect, or cp-kafka-connect-base). Confluent recommends using the Confluent Enterprise distribution of Kafka Connect workers (CE or cp-server-connect). Note that Confluent Enterprise distribution of Kafka Connect workers fails without a valid enterprise license key.
For deploying and running Kafka Connect, Confluent recommends you use the cp-server-connect image.
Note
Starting with Confluent Platform version 8.3.0, the cp-server-connect-base and cp-kafka-connect-base Docker images are deprecated and are scheduled for removal in Confluent Platform version 8.4.0. These base images are functionally identical to cp-server-connect and cp-kafka-connect. If you build custom images on top of cp-server-connect-base or cp-kafka-connect-base, migrate to cp-server-connect or cp-kafka-connect respectively.
Use the
cp-server-connectimage as-is and add the connector JARs using volumes.Build a new Docker image that has the new connectors installed as shown in the following examples.
Create a Docker Image containing Confluent Marketplace Connectors
This example shows how to create a Docker image that extends from one of Confluent’s Kafka Connect images but which contains a custom set of connectors. This may be useful if you’d like to use a connector that isn’t contained in the cp-server-connect image, or if you’d like to keep the custom image lightweight and not include any connectors that you don’t plan to use.
Add connectors from Confluent Marketplace.
Choose an image to extend.
This example uses the
cp-server-connectimage.Choose the connectors from Confluent Marketplace that you’d like to include in your custom image. Note that the remaining steps result in a custom image containing a MongoDB connector, a Microsoft Azure IoT Hub connector, and a Google BigQuery connector.
Write a Dockerfile.
FROM confluentinc/cp-server-connect:<version> RUN confluent connect plugin install --force hpgrahsl/kafka-connect-mongodb:1.1.0 \ && confluent connect plugin install --force microsoft/kafka-connect-iothub:0.6 \ && confluent connect plugin install --force wepay/kafka-connect-bigquery:1.1.0
Build the Dockerfile.
docker build . -t my-custom-image:1.0.0
The output from that command should resemble:
Step 1/2 : FROM confluentinc/cp-server-connect ---> e0d92da57dc3 ... Running in a "--no-prompt" mode Implicit acceptance of the license below: Apache 2.0 https://github.com/wepay/kafka-connect-bigquery/blob/master/LICENSE.md Implicit confirmation of the question: You are about to install 'kafka-connect-bigquery' from WePay, as published on Confluent Hub. Downloading component BigQuery Sink Connector 1.1.0, provided by WePay from Confluent Hub and installing into /usr/share/confluent-hub-components Adding installation directory to plugin path in the following files: /etc/kafka/connect-distributed.properties /etc/kafka/connect-standalone.properties /etc/schema-registry/connect-avro-distributed.properties /etc/schema-registry/connect-avro-standalone.properties Completed Removing intermediate container 48d4506b8a83 ---> 496befc3d3f7 Successfully built 496befc3d3f7 Successfully tagged my-custom-image:1.0.0
This results in an image named
my-custom-imagethat contains the MongoDB, Azure IoT Hub, and BigQuery connectors, and which is capable of running any or all of the connectors using the Kafka Connect framework.
If you are using a docker-compose.yml file and the Confluent Marketplace Client to build your Kafka environment, use the following properties to enable a connector.
connect:
image: confluentinc/kafka-connect-datagen:latest
build:
context: .
dockerfile: Dockerfile-confluenthub
Create a Docker Image containing Local Connectors
This example shows how to create a Docker image that extends the cp-server-connect image to contain one or more local connectors. This is useful if you want to use your connectors instead of pulling connectors from Confluent Marketplace.
Package your local connector in a zip file.
Set up the Dockerfile as shown in the example below.
FROM confluentinc/cp-server-connect:<version> COPY target/components/packages/my-connector-<version>.zip /tmp/my-connector-<version>.zip RUN confluent-hub install --no-prompt /tmp/my-connector-<version>.zip
Build the Dockerfile.
docker build . -t my-custom-image:1.0.0
Add Additional Software
This example shows how to add new software to an image. For example, you might want to extend the Kafka Connect client to include the MySQL JDBC driver. If this approach is used to add new connectors to an image, the connector JARs must be on the plugin.path or the CLASSPATH for the Connect framework.
Write the Dockerfile.
FROM confluentinc/cp-server-connect ENV MYSQL_DRIVER_VERSION 5.1.39 RUN curl -k -SL "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-${MYSQL_DRIVER_VERSION}.tar.gz" \ | tar -xzf - -C /usr/share/confluent-hub-components/confluentinc-kafka-connect-jdbc/lib \ --strip-components=1 mysql-connector-java-5.1.39/mysql-connector-java-${MYSQL_DRIVER_VERSION}-bin.jar
Build the image.
docker build -t foo/mysql-connect:latest .
Note
This approach can also be used to create images with your own Kafka Connect Plugins.
