You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/07/28 08:10:11 UTC
[camel-k-examples] branch main updated (e4a67a6 -> b18cac2)
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
from e4a67a6 add more infomation to ibm-mq/README.md
new b40180b format code in kafka example
new 06e07ec fix: add quotes to sasl_ssl/application.properties file
new ef7241e provide more context to kafka/sasl_ssl example
new 4b323df fix error and improve kafka example README.md
new 3cf15b4 format text and change commands in kafka/readme.md
new b18cac2 add indentation in kafka example
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
generic-examples/kafka/README.md | 48 ++++++++++++++++------
generic-examples/kafka/SampleKafkaConsumer.java | 16 ++++----
generic-examples/kafka/application.properties | 2 +-
generic-examples/kafka/sasl_ssl/README.md | 8 ++--
.../kafka/sasl_ssl/SaslSSLKafkaConsumer.java | 8 ++--
.../kafka/sasl_ssl/SaslSSLKafkaProducer.java | 14 +++----
.../kafka/sasl_ssl/application.properties | 2 +-
7 files changed, 61 insertions(+), 37 deletions(-)
[camel-k-examples] 02/06: fix: add quotes to sasl_ssl/application.properties file
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit 06e07ec5888ab60ad950e48488fc584b8b41ba05
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Wed Jul 27 18:48:52 2022 +0100
fix: add quotes to sasl_ssl/application.properties file
---
generic-examples/kafka/sasl_ssl/application.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/generic-examples/kafka/sasl_ssl/application.properties b/generic-examples/kafka/sasl_ssl/application.properties
index 84b089b..fd68dae 100644
--- a/generic-examples/kafka/sasl_ssl/application.properties
+++ b/generic-examples/kafka/sasl_ssl/application.properties
@@ -20,7 +20,7 @@ camel.component.kafka.brokers = ********.kafka.mycloud.com:443
camel.component.kafka.security-protocol = SASL_SSL
camel.component.kafka.sasl-mechanism = PLAIN
-camel.component.kafka.sasl-jaas-config=org.apache.kafka.common.security.plain.PlainLoginModule required username=*** password=***;
+camel.component.kafka.sasl-jaas-config=org.apache.kafka.common.security.plain.PlainLoginModule required username='***' password='***';
consumer.topic = test
producer.topic = test
\ No newline at end of file
[camel-k-examples] 03/06: provide more context to kafka/sasl_ssl example
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit ef7241e396f0dc4f233b70defbe32c6fb88b7f30
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Wed Jul 27 18:56:07 2022 +0100
provide more context to kafka/sasl_ssl example
---
generic-examples/kafka/sasl_ssl/README.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/generic-examples/kafka/sasl_ssl/README.md b/generic-examples/kafka/sasl_ssl/README.md
index d6a5a29..0335683 100644
--- a/generic-examples/kafka/sasl_ssl/README.md
+++ b/generic-examples/kafka/sasl_ssl/README.md
@@ -1,14 +1,16 @@
# Kafka Camel K SASL SSL example
-This example shows how Camel K can be used to connect to a generic Kafka broker using SASL SSL authentication mechanism. Edit the `application` properties file with the proper values to be able to authenticate a Kafka Broker and use any Topic.
+This example shows how Camel K can be used to connect to a generic Kafka broker that uses `SSL` and `SASL`.
## Prerequisite
-You have a Kafka broker available on the cluster, or anywhere else accessible from the cluster. You will need to edit the `application.properties` file setting a "kafka broker", a "SASL username" and a "SASL password".
+- A Kafka broker configured to use SSL and SASL for encryption and authentication respectively. It should use the `SASL PLAIN` authentication mechanism in order to use this example.
+- You will also need the kafka bootstrap URL and user/service-account credentials with access permissions to topic . You will need to edit the `application.properties` file, setting `camel.component.kafka.brokers` to the kafka bootstrap server URL; setting `username` to the SASL username or service-account-ID; and setting `password` to the SASL password or service-account-secret.
+- A kafka topic named `test` in the broker.
## Secret Configuration
-For convenience create a secret to contain the sensitive properties in the `application.properties` file:
+For convenience, create a secret to contain the sensitive properties in the `application.properties` file:
```
kubectl create secret generic kafka-props --from-file application.properties
[camel-k-examples] 06/06: add indentation in kafka example
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit b18cac2a5b73362d2df6a7a3f8f9e6066891cbb1
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Thu Jul 28 08:03:34 2022 +0100
add indentation in kafka example
---
generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
index 383f1a0..ed02d75 100644
--- a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
+++ b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
@@ -27,7 +27,7 @@ public class SaslSSLKafkaProducer extends RouteBuilder {
from("timer:foo")
.routeId("FromTimer2Kafka")
.setBody()
- .simple("Message #${exchangeProperty.CamelTimerCounter}")
+ .simple("Message #${exchangeProperty.CamelTimerCounter}")
.to("kafka:{{producer.topic}}")
.log("Message correctly sent to the topic!");
}
[camel-k-examples] 01/06: format code in kafka example
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit b40180b6eae3d011a9c76e9c86878725f2ecc34e
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Wed Jul 27 13:21:07 2022 +0100
format code in kafka example
---
generic-examples/kafka/SampleKafkaConsumer.java | 16 ++++++++--------
.../kafka/sasl_ssl/SaslSSLKafkaConsumer.java | 8 ++++----
.../kafka/sasl_ssl/SaslSSLKafkaProducer.java | 14 +++++++-------
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/generic-examples/kafka/SampleKafkaConsumer.java b/generic-examples/kafka/SampleKafkaConsumer.java
index 20e1eac..aebc3fd 100644
--- a/generic-examples/kafka/SampleKafkaConsumer.java
+++ b/generic-examples/kafka/SampleKafkaConsumer.java
@@ -20,13 +20,13 @@ import org.apache.camel.builder.RouteBuilder;
public class SampleKafkaConsumer extends RouteBuilder {
@Override
public void configure() throws Exception {
- log.info("About to start route: Kafka Server -> Log ");
- from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
- + "&maxPollRecords={{consumer.maxPollRecords}}"
- + "&consumersCount={{consumer.consumersCount}}"
- + "&seekTo={{consumer.seekTo}}"
- + "&groupId={{consumer.group}}")
- .routeId("FromKafka")
- .log("${body}");
+ log.info("About to start route: Kafka Server -> Log ");
+ from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
+ + "&maxPollRecords={{consumer.maxPollRecords}}"
+ + "&consumersCount={{consumer.consumersCount}}"
+ + "&seekTo={{consumer.seekTo}}"
+ + "&groupId={{consumer.group}}")
+ .routeId("FromKafka")
+ .log("${body}");
}
}
diff --git a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
index 42ed3f5..527f689 100644
--- a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
+++ b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaConsumer.java
@@ -22,9 +22,9 @@ import org.apache.camel.builder.RouteBuilder;
public class SaslSSLKafkaConsumer extends RouteBuilder {
@Override
public void configure() throws Exception {
- log.info("About to start route: Kafka -> Log ");
- from("kafka:{{consumer.topic}}")
- .routeId("FromKafka2Log")
- .log("${body}");
+ log.info("About to start route: Kafka -> Log ");
+ from("kafka:{{consumer.topic}}")
+ .routeId("FromKafka2Log")
+ .log("${body}");
}
}
diff --git a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
index 85caeb5..383f1a0 100644
--- a/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
+++ b/generic-examples/kafka/sasl_ssl/SaslSSLKafkaProducer.java
@@ -23,12 +23,12 @@ import org.apache.camel.builder.RouteBuilder;
public class SaslSSLKafkaProducer extends RouteBuilder {
@Override
public void configure() throws Exception {
- log.info("About to start route: Timer -> Kafka ");
- from("timer:foo")
- .routeId("FromTimer2Kafka")
- .setBody()
- .simple("Message #${exchangeProperty.CamelTimerCounter}")
- .to("kafka:{{producer.topic}}")
- .log("Message correctly sent to the topic!");
+ log.info("About to start route: Timer -> Kafka ");
+ from("timer:foo")
+ .routeId("FromTimer2Kafka")
+ .setBody()
+ .simple("Message #${exchangeProperty.CamelTimerCounter}")
+ .to("kafka:{{producer.topic}}")
+ .log("Message correctly sent to the topic!");
}
}
[camel-k-examples] 04/06: fix error and improve kafka example README.md
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit 4b323df3537ff401e49725643f75ca3afc573e00
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Wed Jul 27 18:58:58 2022 +0100
fix error and improve kafka example README.md
---
generic-examples/kafka/README.md | 48 +++++++++++++++++++--------
generic-examples/kafka/application.properties | 2 +-
2 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/generic-examples/kafka/README.md b/generic-examples/kafka/README.md
index a651849..98d7388 100644
--- a/generic-examples/kafka/README.md
+++ b/generic-examples/kafka/README.md
@@ -1,30 +1,52 @@
-# Kafka Camel K examples
+# Camel K with Kafka examples
-This example shows how Camel K can be used to connect to a Kafka broker.
+These examples show how to connect to a Kafka broker in a Camel K integration.
+
+You can find more information about Apache Camel and Apache Camel K on the [official Camel website](https://camel.apache.org).
+
+## Before you begin
+
+Read the general instructions in the [root README.md file](/README.md) for setting up your environment and the Kubernetes cluster before looking at this example.
+
+Make sure you've read the [installation instructions](https://camel.apache.org/camel-k/latest/installation/installation.html) for your specific
+cluster before starting the example.
+
+## Additional Requirements for running the examples
+**A Kafka broker**: handles the storage and passing of messages.
## Authentication to Kafka
-We have a dedicated section to show [how to authenticate Camel K to Kafka](./sasl_ssl/).
+To use Kafka with authentication, we have a dedicated section to show [how to authenticate Camel K to Kafka](./sasl_ssl/). \
+For a simple use case without client authentication, continue with this guide.
+
+## Understanding the example
+- [SampleKafkaConsumer.java](./SampleKafkaConsumer.java): contains a route that reads message from a kafka topic and logs the message
+- [application.properties](./application.properties): holds properties required to connect to kafka broker and read from topic.
## Simple usage
-To run this example first set-up Kafka on your k8s cluster.
-A convenient way to do so is by using the Strimzi project, if you are using minikube follow these instructions at https://strimzi.io/quickstarts/minikube/
+To run this example, first set-up Kafka on your k8s cluster.
+A convenient way to do so is by using the Strimzi project. Visit https://strimzi.io/quickstarts/ for set-up instructions. For the instructions on the linked site, it will suffice to only apply the Strimzi installation file and provision the kafka cluster.
-For convenience create a configmap to contain the properties:
+IMPORTANT: The `kafka.host` value in `application.properties` needs to be set to the CLUSTER-IP address of the my-cluster-kafka-bootstrap service in the kafka namespace. To do this run:
```
-kubectl create configmap kafka.props --from-file=examples/kafka/application.properties
+kafkaip=`kubectl get svc/my-cluster-kafka-bootstrap -n kafka -ojsonpath="{.spec.clusterIP}"`; sed -i "/kafka\.host/s/<.*>/$kafkaip/g" application.properties
+```
+
+Create a configmap to contain the properties:
+```
+kubectl create configmap kafka.props --from-file=application.properties
```
-IMPORTANT: The kafka.host value in application.properties needs to be set to the CLUSTER-IP address of the my-cluster-kafka-bootstrap service in the kafka namespace:
- `kubectl get services -n kafka | grep my-cluster-kafka-bootstrap | awk '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ {print $3}'`
+
Finally run this sample using the command:
```
-./kamel run examples/kafka/SampleKafkaConsumer.java --config=configmap:kafka.props
+kamel run SampleKafkaConsumer.java --config=configmap:kafka.props --dev
```
-To create messages to be read use the producer command from the Strimzi page:
+To create messages to be read, use the producer command from the Strimzi page. Run in another terminal:
+```
+kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.30.0-kafka-3.2.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic
```
-kubectl -n kafka run kafka-producer -ti --image=strimzi/kafka:0.11.1-kafka-2.1.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --broker-list my-cluster-kafka-bootstrap:9092 --topic my-topic
-```
\ No newline at end of file
+You should see a prompt where you can type messages to be sent to the `my-topic` topic.
\ No newline at end of file
diff --git a/generic-examples/kafka/application.properties b/generic-examples/kafka/application.properties
index 5723932..74959e2 100644
--- a/generic-examples/kafka/application.properties
+++ b/generic-examples/kafka/application.properties
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-kafka.host=<see SampleKafkaConsumer.java for value to set here>
+kafka.host=<Kafka Bootstrap IP>
kafka.port=9092
consumer.topic=my-topic
consumer.maxPollRecords=5000
[camel-k-examples] 05/06: format text and change commands in kafka/readme.md
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit 3cf15b4d67c48d7640983980e94a74b1c0b0c8ca
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Thu Jul 28 08:00:26 2022 +0100
format text and change commands in kafka/readme.md
---
generic-examples/kafka/README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/generic-examples/kafka/README.md b/generic-examples/kafka/README.md
index 98d7388..41545d6 100644
--- a/generic-examples/kafka/README.md
+++ b/generic-examples/kafka/README.md
@@ -28,7 +28,7 @@ For a simple use case without client authentication, continue with this guide.
To run this example, first set-up Kafka on your k8s cluster.
A convenient way to do so is by using the Strimzi project. Visit https://strimzi.io/quickstarts/ for set-up instructions. For the instructions on the linked site, it will suffice to only apply the Strimzi installation file and provision the kafka cluster.
-IMPORTANT: The `kafka.host` value in `application.properties` needs to be set to the CLUSTER-IP address of the my-cluster-kafka-bootstrap service in the kafka namespace. To do this run:
+**IMPORTANT:** The `kafka.host` value in `application.properties` needs to be set to the CLUSTER-IP address of the my-cluster-kafka-bootstrap service in the kafka namespace. To do this run:
```
kafkaip=`kubectl get svc/my-cluster-kafka-bootstrap -n kafka -ojsonpath="{.spec.clusterIP}"`; sed -i "/kafka\.host/s/<.*>/$kafkaip/g" application.properties
```
@@ -42,11 +42,11 @@ kubectl create configmap kafka.props --from-file=application.properties
Finally run this sample using the command:
```
-kamel run SampleKafkaConsumer.java --config=configmap:kafka.props --dev
+kamel run SampleKafkaConsumer.java --config=configmap:kafka.props
```
To create messages to be read, use the producer command from the Strimzi page. Run in another terminal:
```
-kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.30.0-kafka-3.2.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic
+kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.30.0-kafka-3.2.0 --rm --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic
```
You should see a prompt where you can type messages to be sent to the `my-topic` topic.
\ No newline at end of file