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/28 14:05:17 UTC

[camel-k] branch master updated (95dd165 -> 9d5467a)

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

nferraro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from 95dd165  Updated CHANGELOG.md
     new df577c3  doc(examples): refactory timer-source kamelet example
     new 9d5467a  doc(examples): timer source to log sink kamelet example

The 2 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:
 .../timer-source-log-sink/log-sink.binding.yaml    |  4 +-
 .../timer-source-log-sink/log-sink.kamelet.yaml    | 34 +++++++++++
 examples/kamelets/timer-source-log-sink/readme.md  | 62 ++++++++++++++++++++
 .../timer-source-log-sink/timer-events.yaml}       |  2 +-
 .../timer-source.binding.yaml}                     |  4 +-
 .../timer-source.kamelet.yaml                      |  2 +-
 .../kamelet-binding-example.yaml                   |  0
 .../{ => timer-source}/messages-channel.yaml       |  0
 examples/kamelets/timer-source/readme.md           | 66 ++++++++++++++++++++++
 .../{ => timer-source}/timer-source.kamelet.yaml   |  0
 examples/kamelets/{ => timer-source}/usage.groovy  |  0
 11 files changed, 168 insertions(+), 6 deletions(-)
 copy e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml => examples/kamelets/timer-source-log-sink/log-sink.binding.yaml (95%)
 create mode 100644 examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml
 create mode 100644 examples/kamelets/timer-source-log-sink/readme.md
 copy examples/{knative/words-channel.yaml => kamelets/timer-source-log-sink/timer-events.yaml} (98%)
 copy examples/kamelets/{kamelet-binding-example.yaml => timer-source-log-sink/timer-source.binding.yaml} (96%)
 copy examples/kamelets/{ => timer-source-log-sink}/timer-source.kamelet.yaml (99%)
 rename examples/kamelets/{ => timer-source}/kamelet-binding-example.yaml (100%)
 rename examples/kamelets/{ => timer-source}/messages-channel.yaml (100%)
 create mode 100644 examples/kamelets/timer-source/readme.md
 rename examples/kamelets/{ => timer-source}/timer-source.kamelet.yaml (100%)
 rename examples/kamelets/{ => timer-source}/usage.groovy (100%)


[camel-k] 01/02: doc(examples): refactory timer-source kamelet example

Posted by nf...@apache.org.
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 df577c329a1efb115a494c07c707806eff9a48dd
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Oct 23 15:41:53 2020 +0200

    doc(examples): refactory timer-source kamelet example
    
    * Adding a dedicated folder for the timer-source example
    * Adding a readme.md to briefly illustrate the example
---
 .../kamelet-binding-example.yaml                   |  0
 .../{ => timer-source}/messages-channel.yaml       |  0
 examples/kamelets/timer-source/readme.md           | 66 ++++++++++++++++++++++
 .../{ => timer-source}/timer-source.kamelet.yaml   |  0
 examples/kamelets/{ => timer-source}/usage.groovy  |  0
 5 files changed, 66 insertions(+)

diff --git a/examples/kamelets/kamelet-binding-example.yaml b/examples/kamelets/timer-source/kamelet-binding-example.yaml
similarity index 100%
rename from examples/kamelets/kamelet-binding-example.yaml
rename to examples/kamelets/timer-source/kamelet-binding-example.yaml
diff --git a/examples/kamelets/messages-channel.yaml b/examples/kamelets/timer-source/messages-channel.yaml
similarity index 100%
rename from examples/kamelets/messages-channel.yaml
rename to examples/kamelets/timer-source/messages-channel.yaml
diff --git a/examples/kamelets/timer-source/readme.md b/examples/kamelets/timer-source/readme.md
new file mode 100644
index 0000000..25d27fd
--- /dev/null
+++ b/examples/kamelets/timer-source/readme.md
@@ -0,0 +1,66 @@
+# Timer Source Hello World example
+
+This example shows how to create a simple timer-source `kamelet` and how to use it in a new integration or how to bind it to a knative destination through a `KameletBinding`.
+
+## Timer Source Kamelet
+
+First of all, you must install the timer source kamelet defined in `timer-source.kamelet.yaml` file:
+```
+$ kubectl apply -f timer-source.kamelet.yaml
+```
+You can check the newly created `kamelet` checking the list of kamelets available:
+```
+$ kubectl get kamelets
+
+NAME                   PHASE
+timer-source           Ready
+```
+## Timer Source integration
+As soon as the `kamelet` is available in your cluster, you can use it in any integration such as the one defined in `usage.groovy` file:
+```
+from('kamelet:timer-source?message=Hello+Kamelets&period=1000')
+    .log('${body}')
+```
+Just run the integration via:
+```
+$ kamel run usage.groovy
+```
+You should be able to see the new integration running after some time:
+```
+$ kamel get
+NAME	PHASE	KIT
+usage	Running	kit-bu9d2r22hhmoa6qrtc2g
+```
+As soon as the integration starts, you will be able to log the timer source events emitted:
+```
+$ kamel log usage
+
+[1] Monitoring pod usage-785d65897b-5jdvp
+...
+[1] 2020-10-23 12:51:19,724 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+[1] 2020-10-23 12:51:20,681 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+[1] 2020-10-23 12:51:21,682 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+[1] 2020-10-23 12:51:22,681 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+[1] 2020-10-23 12:51:23,684 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+[1] 2020-10-23 12:51:24,682 INFO  [route1] (Camel (camel-1) thread #0 - timer://tick) Hello Kamelets
+....
+```
+## Timer Source KameletBinding
+You can also bind the `kamelet` to a knative destination (or other events channel, [see the official documention](https://camel.apache.org/camel-k/latest/kamelets/kamelets.html#kamelets-usage-binding)) in order to source the events emitted by the configuration described by the `kamelet`. Make sure to have Knative properly installed on your cluster ([see installation guide](https://knative.dev/docs/install/)).
+
+First of all, you must declare the knative destination:
+```
+kubectl apply -f messages-channel.yaml
+```
+Once the destination is ready, you can reference it from a `KameletBinding` such as in the example `kamelet-binding-example.yaml`. In order to bind the connector to the destination apply the configuration:
+```
+$ kubectl apply -f kamelet-binding-example.yaml
+```
+You can confirm the creation of the `KameletBinding` listing the resources:
+```
+$ kubectl get kameletbindings
+
+NAME           PHASE
+timer-source   Ready
+```
+At this stage you will be able to consume the timer event sources from the knative destination.
diff --git a/examples/kamelets/timer-source.kamelet.yaml b/examples/kamelets/timer-source/timer-source.kamelet.yaml
similarity index 100%
rename from examples/kamelets/timer-source.kamelet.yaml
rename to examples/kamelets/timer-source/timer-source.kamelet.yaml
diff --git a/examples/kamelets/usage.groovy b/examples/kamelets/timer-source/usage.groovy
similarity index 100%
rename from examples/kamelets/usage.groovy
rename to examples/kamelets/timer-source/usage.groovy


[camel-k] 02/02: doc(examples): timer source to log sink kamelet example

Posted by nf...@apache.org.
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 9d5467a7d7504883f0c887ac7dc01d2d1d8aa173
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Oct 23 16:32:25 2020 +0200

    doc(examples): timer source to log sink kamelet example
---
 .../timer-source-log-sink/log-sink.binding.yaml    | 32 +++++++++++
 .../timer-source-log-sink/log-sink.kamelet.yaml    | 34 ++++++++++++
 examples/kamelets/timer-source-log-sink/readme.md  | 62 ++++++++++++++++++++++
 .../timer-source-log-sink/timer-events.yaml        | 21 ++++++++
 .../timer-source.binding.yaml                      | 34 ++++++++++++
 .../timer-source.kamelet.yaml                      | 54 +++++++++++++++++++
 6 files changed, 237 insertions(+)

diff --git a/examples/kamelets/timer-source-log-sink/log-sink.binding.yaml b/examples/kamelets/timer-source-log-sink/log-sink.binding.yaml
new file mode 100644
index 0000000..6b6608c
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/log-sink.binding.yaml
@@ -0,0 +1,32 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: log-event-sink
+spec:
+  source:
+    ref:
+      kind: InMemoryChannel
+      apiVersion: messaging.knative.dev/v1beta1
+      name: messages
+  sink:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: log-sink
diff --git a/examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml b/examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml
new file mode 100644
index 0000000..0d9ff42
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml
@@ -0,0 +1,34 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: log-sink
+  annotations:
+    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAACcBJREFUeJzt3XmsHVUdwPHva21poWGTUpAiVRQSFjWAyi5LcCmKLCEouLwQccMgGsISEkQRXMIfSKMGhQSMCCibkRIgghQEF4RIQYtG4YFsraRlb6G+1j9+94a50/fmvuW+OTN3vp9kkrnnzj3zu+/N786ZmTNnQJIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZKkfjOQOoAKGQA+DJwAvBfYCpieNKKJexk4E/h56kDUH94O3AOs76NpHfDlXv6R1Ey7ACtIv0FP1XRa7/5Uapo5wL9JvxFP9fSNXv3Bmu [...]
+  labels:
+    camel.apache.org/kamelet.type: "sink"
+spec:
+  definition:
+    title: "Log Sink"
+    description: "Consume events from a channel"
+  flow:
+    from:
+      uri: kamelet:source
+      steps:
+      - to: "log:sink"
diff --git a/examples/kamelets/timer-source-log-sink/readme.md b/examples/kamelets/timer-source-log-sink/readme.md
new file mode 100644
index 0000000..4d4d671
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/readme.md
@@ -0,0 +1,62 @@
+# Timer Source to Log Sink
+
+This example shows how to create a simple timer `event source` and a log `event sink`. The timer events emitted are consumed by a simple logging connector which will print out those events.
+
+## Create events source and sink
+
+Let's start by creating the timer event source and log event sink as `kamelet`s.
+```
+$ kubectl apply -f timer-source.kamelet.yaml
+$ kubectl apply -f log-sink.kamelet.yaml
+```
+
+You can check the newly created `kamelet`s in the list.
+```
+$ kubectl get kamelets
+
+NAME           PHASE
+log-sink       Ready
+timer-source   Ready
+```
+
+## Create channel destination
+
+Let's continue by creating a `knative` destination.
+```
+$ kubectl apply -f timer-events.yaml
+```
+
+## Binding events
+
+We can now bind the timer event source to produce events on the destination with the `timer-source.binding.yaml` configuration.
+```
+$ kubectl apply -f timer-source.binding.yaml
+```
+In a similar fashion you can bind to the log sink in order to consume those events with the `log-sink.binding.yaml` configuration.
+```
+$ kubectl apply -f log-sink.binding.yaml
+```
+You can check the newly created bindings listing the `KameletBidings`.
+```
+$ kubectl get KameletBindings
+
+NAME                 PHASE
+log-event-sink       Ready
+timer-event-source   Ready
+```
+
+### Watch the event sink
+
+After a while you will be able to watch the event consumed by the underlying `log-event-sink` integration:
+
+```
+$ kamel log log-event-sink
+
+[1] Monitoring pod log-event-sink-wjm9w-deployment-cf4f49655-xwq82
+...
+[1] 2020-10-23 14:28:11,878 INFO  [sink] (vert.x-worker-thread-1) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
+[1] 2020-10-23 14:28:11,877 INFO  [sink] (vert.x-worker-thread-0) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
+[1] 2020-10-23 14:28:12,381 INFO  [sink] (vert.x-worker-thread-2) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
+[1] 2020-10-23 14:28:13,276 INFO  [sink] (vert.x-worker-thread-3) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
+[1] 2020-10-23 14:28:14,299 INFO  [sink] (vert.x-worker-thread-4) Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: Hello world!]
+```
\ No newline at end of file
diff --git a/examples/kamelets/timer-source-log-sink/timer-events.yaml b/examples/kamelets/timer-source-log-sink/timer-events.yaml
new file mode 100644
index 0000000..b7b4133
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/timer-events.yaml
@@ -0,0 +1,21 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+apiVersion: messaging.knative.dev/v1beta1
+kind: InMemoryChannel
+metadata:
+  name: messages
\ No newline at end of file
diff --git a/examples/kamelets/timer-source-log-sink/timer-source.binding.yaml b/examples/kamelets/timer-source-log-sink/timer-source.binding.yaml
new file mode 100644
index 0000000..622e015
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/timer-source.binding.yaml
@@ -0,0 +1,34 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: timer-event-source
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: timer-source
+    properties:
+      message: "Hello world!"
+  sink:
+    ref:
+      kind: InMemoryChannel
+      apiVersion: messaging.knative.dev/v1beta1
+      name: messages
\ No newline at end of file
diff --git a/examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml b/examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml
new file mode 100644
index 0000000..47a6393
--- /dev/null
+++ b/examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml
@@ -0,0 +1,54 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: timer-source
+  annotations:
+    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gU3ZnIFZlY3RvciBJY29ucyA6IGh0dHA6Ly93d3cub25saW5ld2ViZm9udHMuY29tL2ljb24gLS0+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm [...]
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "Timer Source"
+    description: "Produces periodic events with a custom payload"
+    required:
+      - message
+    properties:
+      period:
+        title: Period
+        description: The interval between two events
+        type: integer
+        default: 1000
+      message:
+        title: Message
+        description: The message to generate
+        type: string
+        example: "hello world"
+  types:
+    out:
+      mediaType: text/plain
+  flow:
+    from:
+      uri: timer:tick
+      parameters:
+        period: "#property:period"
+      steps:
+      - set-body:
+          constant: "{{message}}"
+      - to: "kamelet:sink"
\ No newline at end of file