You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/01/20 08:27:09 UTC

[camel-kafka-connector-examples] branch master updated: Added a docker pull sink connector example

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git


The following commit(s) were added to refs/heads/master by this push:
     new 5616ebd  Added a docker pull sink connector example
5616ebd is described below

commit 5616ebd46c56a98684551379a5751b57794e79e4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jan 20 09:25:08 2021 +0100

    Added a docker pull sink connector example
---
 docker/docker-sink-pull/README.adoc                | 98 ++++++++++++++++++++++
 .../config/CamelDockerSinkConnector.properties     | 33 ++++++++
 2 files changed, 131 insertions(+)

diff --git a/docker/docker-sink-pull/README.adoc b/docker/docker-sink-pull/README.adoc
new file mode 100644
index 0000000..35e916b
--- /dev/null
+++ b/docker/docker-sink-pull/README.adoc
@@ -0,0 +1,98 @@
+= Camel-Kafka-connector Docker Sink Pull
+
+This is an example for Camel-Kafka-connector Docker Sink Pull
+
+== Standalone
+
+=== What is needed
+
+- A Docker daemon
+
+=== Running Kafka
+
+[source]
+----
+$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties
+$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties
+$KAFKA_HOME/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic mytopic
+----
+
+=== Download the connector package
+
+Download the connector package zip and extract the content to a directory. In this example we'll use `/home/oscerd/connectors/`
+
+[source]
+----
+> cd /home/oscerd/connectors/
+> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-docker-kafka-connector/0.7.0/camel-docker-kafka-connector-0.7.0-package.zip
+> unzip camel-docker-kafka-connector-0.7.0-package.zip
+----
+
+=== Configuring Kafka Connect
+
+You'll need to set up the `plugin.path` property in your kafka
+
+Open the `$KAFKA_HOME/config/connect-standalone.properties` and set the `plugin.path` property to your choosen location:
+
+[source]
+----
+...
+plugin.path=/home/oscerd/connectors
+...
+----
+
+=== Setup the connectors
+
+Open the Docker configuration file at `$EXAMPLES/docker/docker-sink-pull/config/CamelDockerSinkConnector.properties`
+
+[source]
+----
+name=CamelDockerSinkConnector
+connector.class=org.apache.camel.kafkaconnector.docker.CamelDockerSinkConnector
+tasks.max=1
+
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.component.docker.host=/var/run/docker.sock
+camel.component.docker.socket=true
+camel.sink.path.operation=imagepull
+camel.sink.endpoint.repository=memcached
+camel.sink.endpoint.tag=latest
+camel.sink.endpoint.username=<username>
+camel.sink.endpoint.password=<password>
+----
+
+In this case we are using local unix socket.
+
+Add the correct information for username and password.
+
+=== Running the example
+
+Run the kafka connect with the Docker Source connector:
+
+[source]
+----
+$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties $EXAMPLES/docker/docker-sink-pull/config/CamelDockerSinkConnector.properties
+----
+
+On a different terminal run the kafkacat producer
+
+[source]
+----
+> echo "test" | ./kafkacat -b localhost:9092 -t mytopic
+% Auto-selecting Producer mode (use -P or -C to override)
+----
+
+We just need to trigger the operation through a message
+
+After a while we should get a new memcached image in our Docker
+
+[source]
+----
+> docker images
+REPOSITORY                                                               TAG                 IMAGE ID            CREATED             SIZE
+memcached                                                                latest              9f547b64a127        7 days ago          82.4MB
+----
diff --git a/docker/docker-sink-pull/config/CamelDockerSinkConnector.properties b/docker/docker-sink-pull/config/CamelDockerSinkConnector.properties
new file mode 100644
index 0000000..448ba95
--- /dev/null
+++ b/docker/docker-sink-pull/config/CamelDockerSinkConnector.properties
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name=CamelDockerSinkConnector
+connector.class=org.apache.camel.kafkaconnector.docker.CamelDockerSinkConnector
+tasks.max=1
+
+key.converter=org.apache.kafka.connect.storage.StringConverter
+value.converter=org.apache.kafka.connect.storage.StringConverter
+
+topics=mytopic
+
+camel.component.docker.host=/var/run/docker.sock
+camel.component.docker.socket=true
+camel.sink.path.operation=imagepull
+camel.sink.endpoint.repository=memcached
+camel.sink.endpoint.tag=latest
+camel.sink.endpoint.username=<username>
+camel.sink.endpoint.password=<password>