You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/10/06 12:21:49 UTC
[camel-k] 02/02: Fix #1686: update doc
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0b999d00edf13651f7bfa9def218e16b136f35db
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Tue Oct 6 12:12:13 2020 +0200
Fix #1686: update doc
---
docs/modules/ROOT/pages/kamelets/kamelets.adoc | 43 +++++++++++++++++++++++++-
pkg/util/bindings/bindings_test.go | 2 +-
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/docs/modules/ROOT/pages/kamelets/kamelets.adoc b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
index a5d7889..d3a0f2a 100644
--- a/docs/modules/ROOT/pages/kamelets/kamelets.adoc
+++ b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
@@ -250,6 +250,8 @@ doing additional processing (such as tranformations or other enterprise integrat
A common use case is that of **Knative Sources**, for which the Apache Camel developers maintain the https://knative.dev/docs/eventing/samples/apache-camel-source/[Knative CamelSources].
Kamelets represent an **evolution** of the model proposed in CamelSources, but they allow using the same declarative style of binding, via a resource named **KameletBinding**.
+=== Binding to a Knative Destination
+
A KameletBinding allows to declaratively move data from a system described by a Kamelet towards a Knative destination (or other kind of destinations, in the future), or from
a Knative channel/broker to another external system described by a Kamelet.
@@ -289,6 +291,44 @@ A Kamelet of type "sink", by contrast, can only be used in the `sink` section of
**Under the covers, a KameletBinding creates an Integration** resource that implements the binding, but this is transparent to the end user.
+=== Binding to a Kafka Topic
+
+The example seen in the previous paragraph can be also configured to push data a https://strimzi.io/[Strimzi] Kafka topic (Kamelets can be also configured to pull data from topics).
+
+To do so, you need to:
+
+- Install Strimzi on your cluster
+- Create a Strimzi *Kafka* cluster using plain listener and **no authentication**
+- Create a Strimzi *KafkaTopic* named `my-topic`
+
+Refer to the https://strimzi.io/[Strimzi documentation] for instructions on how to do that.
+
+The following binding can be created to push data into the `my-topic` topic:
+
+[source,yaml]
+----
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ name: telegram-text-source-to-kafka
+spec:
+ source:
+ ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: telegram-text-source
+ properties:
+ botToken: the-token-here
+ sink:
+ ref: # <1>
+ kind: KafkaTopic
+ apiVersion: kafka.strimzi.io/v1beta1
+ name: my-topic
+----
+<1> Kubernetes reference to a Strimzi KafkaTopic
+
+After creating it, messages will flow from Telegram to Kafka.
+
=== Binding to an explicit URI
An alternative way to use a KameletBinding is to configure the source/sink to be an explicit Camel URI.
@@ -315,7 +355,8 @@ spec:
This KameletBinding explicitly defines an URI where data is going to be pushed.
-NOTE: the `uri` option is also conventionally used in Knative to specify a non-kubernetes destination
+NOTE: the `uri` option is also conventionally used in Knative to specify a non-kubernetes destination.
+To comply with the Knative specifications, in case an "http" or "https" URI is used, Camel will send https://cloudevents.io/[CloudEvents] to the destination.
[[kamelets-specification]]
== Kamelet Specification
diff --git a/pkg/util/bindings/bindings_test.go b/pkg/util/bindings/bindings_test.go
index 8ad28a2..385febf 100644
--- a/pkg/util/bindings/bindings_test.go
+++ b/pkg/util/bindings/bindings_test.go
@@ -21,13 +21,13 @@ import (
"context"
"encoding/json"
"fmt"
- "github.com/apache/camel-k/pkg/util/test"
"net/url"
"testing"
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/test"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
)