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/07/28 11:11:45 UTC
[camel-k-examples] 01/02: Added Kafka to Log with value to key
sample
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch value-to-key
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
commit 6614c43a07d44f7ec51f6aa30446e06314fb2dae
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 28 13:09:43 2021 +0200
Added Kafka to Log with value to key sample
---
kamelets/kafka-to-log-with-value-to-key/README.md | 18 ++++++++++++
.../flow-binding.yaml | 33 ++++++++++++++++++++++
.../log-sink.kamelet.yaml | 22 +++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/kamelets/kafka-to-log-with-value-to-key/README.md b/kamelets/kafka-to-log-with-value-to-key/README.md
new file mode 100644
index 0000000..acb9fdb
--- /dev/null
+++ b/kamelets/kafka-to-log-with-value-to-key/README.md
@@ -0,0 +1,18 @@
+# Kafka to Log with Value To Key action
+
+- Use the quickstart for https://strimzi.io/quickstarts/ and follow the minikube guide.
+
+- The Log Sink Kamelet is not available out of the box in 1.5.0 Camel-K release so you'll have to install it before installing the flow binding.
+
+- If camel-k has been installed in a specific namespace different from the default one, you'll need to add a parameter to all the commands (-n <namespace_name>)
+
+- Run the following commands
+
+ - kubectl apply -f log-sink.kamelet.yaml -n kafka
+ - kubectl apply -f flow-binding.yaml -n kafka
+
+- Check logs
+
+kamel logs kafka-to-log-with-value-to-key
+
+You should data ingesting into the test-topic topic, you should see logged a record with key composed of foo and bar values.
diff --git a/kamelets/kafka-to-log-with-value-to-key/flow-binding.yaml b/kamelets/kafka-to-log-with-value-to-key/flow-binding.yaml
new file mode 100644
index 0000000..72178f5
--- /dev/null
+++ b/kamelets/kafka-to-log-with-value-to-key/flow-binding.yaml
@@ -0,0 +1,33 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ name: kafka-to-log-with-value-to-key
+spec:
+ source:
+ ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: kafka-not-secured-source
+ properties:
+ brokers: 'my-cluster-kafka-bootstrap:9092'
+ topic: 'test-topic'
+ steps:
+ - ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: json-deserialize-action
+ - ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: value-to-key-action
+ properties:
+ fields: "foo,bar"
+ - ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: json-serialize-action
+ sink:
+ ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: log-sink
diff --git a/kamelets/kafka-to-log-with-value-to-key/log-sink.kamelet.yaml b/kamelets/kafka-to-log-with-value-to-key/log-sink.kamelet.yaml
new file mode 100755
index 0000000..a48fb41
--- /dev/null
+++ b/kamelets/kafka-to-log-with-value-to-key/log-sink.kamelet.yaml
@@ -0,0 +1,22 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+ name: log-sink
+ annotations:
+ camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDAgMjQwIj48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIuNjY3IiB4Mj0iLjQxNyIgeTE9Ii4xNjciIHkyPSIuNzUiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzM3YWVlMiIvPjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzFlOTZjOCIvPjwvbGluZWFyR3JhZGllbnQ+PGxpbmVhckdyYWRpZW50IGlkPSJiIiB4MT0iLjY2IiB4Mj0iLjg1MSIgeTE9Ii40MzciIHkyPSIuODAyIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNlZmY3Zm [...]
+ camel.apache.org/provider: "Apache Software Foundation"
+ labels:
+ camel.apache.org/kamelet.type: "sink"
+ camel.apache.org/kamelet.group: "Log"
+spec:
+ definition:
+ title: "Log Sink"
+ description: |-
+ Log something
+ type: object
+ flow:
+ from:
+ uri: "kamelet:source"
+ steps:
+ - to:
+ uri: "log:info?showAll=true"