diff --git a/generic-examples/README.md b/generic-examples/README.md index 77b4c15..d990676 100644 --- a/generic-examples/README.md +++ b/generic-examples/README.md @@ -4,7 +4,8 @@ This folder contains various examples of `Camel K` integrations. You can use the ## Basic usage examples -In this section you will find the most basic examples. Useful to start learning about Camel K and how to run. You can use many supported languages and learn about the most basic features: +In this section you will find the most basic examples. Useful to start learning about Camel K and how to run. +You can use many supported languages and learn about the most basic features: | Type | Description | Link | |-------------------|---------------------------------------------------------------------------------------------------|--------------------------------| @@ -21,7 +22,8 @@ In this section you will find the most basic examples. Useful to start learning ## Component usage examples -In this section you can find a few examples of certain [`Camel` components](https://camel.apache.org/components/latest/index.html). This is a limited number of the wide variety of components supported by Apache Camel. You can also find useful examples [in this repository](https://github.com/apache/camel-k-examples). +In this section you can find a few examples of certain [`Camel` components](https://camel.apache.org/components/latest/index.html). This is a limited number of the wide variety of components supported by Apache Camel. +You can also find useful examples [in this repository](https://github.com/apache/camel-k-examples). | Type | Description | Link | |------------|-----------------|------------------------------| @@ -35,17 +37,16 @@ In this section you can find a few examples of certain [`Camel` components](http ## Advanced usage examples -As soon as you will learn the basic stuff, you will like to try the new advanced feature offered by Camel K. Here a few examples: - -| Type | Description | Link | -|----------|-----------------------------------------------------------------------------------------|-----------------------------| -| Kamelets | How to use [`Kamelet`s](https://camel.apache.org/camel-k/latest/kamelets/kamelets.html) | [see examples](./kamelets/) | -| Master | Master support example | [see examples](./master/) | -| OLM | OPERATOR Lifecycle manager installation example | [see examples](./olm/) | -| Polyglot | Polyglot integration examples | [see examples](./polyglot/) | -| Pulsar | Pulsar usage | [see examples](./pulsar/) | -| Saga | Saga pattern example | [see examples](./saga/) | -| Tekton | Tekton tutorial | [see examples](./tekton/) | +When you feel comfortable with basic stuff, you may want to try the more advanced features offered by Camel K. Here a few examples: + +| Type | Description | Link | +|----------|---------------------------------------------------------------------------------------|-----------------------------| +| Kamelets | How to use [Kamelets](https://camel.apache.org/camel-k/latest/kamelets/kamelets.html) | [see examples](./kamelets/) | +| Master | Master support example | [see examples](./master/) | +| Polyglot | Polyglot integration examples | [see examples](./polyglot/) | +| Pulsar | Pulsar usage | [see examples](./pulsar/) | +| Saga | Saga pattern example | [see examples](./saga/) | +| Tekton | Tekton tutorial | [see examples](./tekton/) | ## Traits usage examples diff --git a/generic-examples/amqp/README.md b/generic-examples/amqp/README.md index 4abcb6f..7f701ec 100644 --- a/generic-examples/amqp/README.md +++ b/generic-examples/amqp/README.md @@ -19,7 +19,7 @@ cluster before starting the example. - [`AmqpConnectionBeanProducer.java`](./AmqpConnectionBeanProducer.java) defines a route that generates a message every second and sends it to an amqp queue. - [`AmqpConnectionBeanConsumer.java`](./AmqpConnectionBeanConsumer.java) consumes messages from the amqp queue, logs them to the logger using the info level -- [`amqp.groovy`](./amqp.groovy) generates a message every second and sends to amqp topic +- [`amqp.yaml`](./amqp.yaml) generates a message every second and sends to amqp topic - [`amqp.properties`](./amqp.properties) holds required credentials to connect to broker. ## Running the Example diff --git a/generic-examples/cron/README.md b/generic-examples/cron/README.md index f3d1fea..ba6bd9b 100644 --- a/generic-examples/cron/README.md +++ b/generic-examples/cron/README.md @@ -24,7 +24,7 @@ In order to follow this example: ## Understanding the Example This example uses the cron component to trigger a route at a specific time interval specified in a cron expression. The route transforms data from the cron source and sends it to the logger. -The integration is all contained in a single file named `cron.groovy` +The integration is all contained in a single file named `cron.yaml` ## Running the Example diff --git a/generic-examples/kamelets/chuck-norris/chuck.xml b/generic-examples/kamelets/chuck-norris/chuck.xml deleted file mode 100644 index 2400f58..0000000 --- a/generic-examples/kamelets/chuck-norris/chuck.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/generic-examples/kamelets/chuck-norris/chuck.yaml b/generic-examples/kamelets/chuck-norris/chuck.yaml new file mode 100644 index 0000000..041e2da --- /dev/null +++ b/generic-examples/kamelets/chuck-norris/chuck.yaml @@ -0,0 +1,23 @@ +# camel-k: language=yaml + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "kamelet:chuck-norris-source" + steps: + - to: "log:info" diff --git a/generic-examples/kamelets/chuck-norris/readme.md b/generic-examples/kamelets/chuck-norris/readme.md index e02f312..33388bd 100644 --- a/generic-examples/kamelets/chuck-norris/readme.md +++ b/generic-examples/kamelets/chuck-norris/readme.md @@ -6,15 +6,16 @@ This example shows how you can use an out of the box Kamelet with your Camel app This example uses the Chuck Norris Kamelet that periodically gets a joke from the Chuck Norris internet database. -A Camel routes is _coded_ in the `chuck.xml` file using the XML DSL that uses the Kamelet, +A Camel routes is _coded_ in the `chuck.yaml` file using the XML DSL that uses the Kamelet, and log the result from the Kamelet to the console. ## Running the example Just run the integration via: ``` -$ kamel run chuck.xml +$ kamel run chuck.yaml ``` + You should be able to see the new integration running after some time: ``` $ kamel get diff --git a/generic-examples/kamelets/kameletbindings/README.md b/generic-examples/kamelets/kameletbindings/README.md index 487c721..71a2b83 100644 --- a/generic-examples/kamelets/kameletbindings/README.md +++ b/generic-examples/kamelets/kameletbindings/README.md @@ -1,24 +1,26 @@ -# KameletBindings examples +# Kamelet Pipe examples -Find useful examples about how to use KameletBindings. +Find useful examples about how to use Pipes. ## Understanding the examples - [env-var-writer.kamelet.yaml](./env-var-writer.kamelet.yaml): sink kamelet, logs specified env variables. -- [kb-env-vars.yaml](./kb-env-vars.yaml): kamelet binding, connects the _env-var-writer_ kamelet directly to a Camel URI, adds env variables to the integration container using the `environment` trait. -- [kb-log-trait-annotation.yaml](./kb-log-trait-annotation.yaml): kamelet binding, connects two Camel URIs, uses the `logging` trait to customize the integration behaviour. +- [kamelet-pipe-env-vars.yaml](./kamelet-pipe-env-vars.yaml): kamelet pipe, connects the _env-var-writer_ kamelet directly to a Camel URI, adds env variables to the integration container using the `environment` trait. +- [kamelet-pipe-log-trait-annotation.yaml](./kamelet-pipe-log-trait-annotation.yaml): kamelet pipe, connects two Camel URIs, uses the `logging` trait to customize the integration behaviour. ## Running the examples -### Timer-to-Log kamelet binding -First, we apply the kamelet used in this binding: + +### Timer-to-Log kamelet pipe + +First, we apply the sink kamelet used in this example: ``` kubectl apply -f env-var-writer.kamelet.yaml ``` -Next, we apply the kamelet binding +Next, we apply the source kamelet that connects to the sink via a pipe ``` -kubectl apply -f kb-env-vars.yaml +kubectl apply -f kamelet-pipe-env-vars.yaml ``` -A _timer-to-log_ integration is created that implements the binding. To view the logs, run: +A _timer-to-log_ integration is created. To view the logs, run: ``` kamel log timer-to-log ... @@ -27,11 +29,13 @@ kamel log timer-to-log ... ``` -### Timer-2-Log-Annotation kamelet binding +### Timer-2-Log-Annotation kamelet pipe + Apply the kamelet binding: ``` -kubectl apply -f kb-log-trait-annotation.yaml +kubectl apply -f kamelet-pipe-log-trait-annotation.yaml ``` + A _timer-2-log-annotation_ integration is created that implements the binding. You should see information logged at the `DEBUG` level. The messages should NOT use color. To view the logs: ``` kamel log timer-2-log-annotation diff --git a/generic-examples/kamelets/kameletbindings/env-var-writer.kamelet.yaml b/generic-examples/kamelets/kameletbindings/env-var-writer.kamelet.yaml index 65e3922..5a30591 100644 --- a/generic-examples/kamelets/kameletbindings/env-var-writer.kamelet.yaml +++ b/generic-examples/kamelets/kameletbindings/env-var-writer.kamelet.yaml @@ -15,7 +15,7 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 +apiVersion: camel.apache.org/v1 kind: Kamelet metadata: name: env-var-writer diff --git a/generic-examples/kamelets/kameletbindings/kb-env-vars.yaml b/generic-examples/kamelets/kameletbindings/kamelet-pipe-env-vars.yaml similarity index 92% rename from generic-examples/kamelets/kameletbindings/kb-env-vars.yaml rename to generic-examples/kamelets/kameletbindings/kamelet-pipe-env-vars.yaml index c0b8bc6..4a70b0d 100644 --- a/generic-examples/kamelets/kameletbindings/kb-env-vars.yaml +++ b/generic-examples/kamelets/kameletbindings/kamelet-pipe-env-vars.yaml @@ -21,8 +21,8 @@ # Apply kamelet binding # kubectl apply -f kb-env-vars.yaml # -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding +apiVersion: camel.apache.org/v1 +kind: Pipe metadata: name: timer-to-log annotations: @@ -33,5 +33,5 @@ spec: sink: ref: kind: Kamelet - apiVersion: camel.apache.org/v1alpha1 + apiVersion: camel.apache.org/v1 name: env-var-writer diff --git a/generic-examples/kamelets/kameletbindings/kb-log-trait-annotation.yaml b/generic-examples/kamelets/kameletbindings/kamelet-pipe-log-trait-annotation.yaml similarity index 95% rename from generic-examples/kamelets/kameletbindings/kb-log-trait-annotation.yaml rename to generic-examples/kamelets/kameletbindings/kamelet-pipe-log-trait-annotation.yaml index 73a5d6a..f16dc55 100644 --- a/generic-examples/kamelets/kameletbindings/kb-log-trait-annotation.yaml +++ b/generic-examples/kamelets/kameletbindings/kamelet-pipe-log-trait-annotation.yaml @@ -15,8 +15,8 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding +apiVersion: camel.apache.org/v1 +kind: Pipe metadata: name: timer-2-log-annotation annotations: diff --git a/generic-examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml b/generic-examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml index ee0766c..18de8ca 100644 --- a/generic-examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml +++ b/generic-examples/kamelets/timer-source-log-sink/log-sink.kamelet.yaml @@ -15,7 +15,7 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 +apiVersion: camel.apache.org/v1 kind: Kamelet metadata: name: log-sink diff --git a/generic-examples/kamelets/timer-source-log-sink/log-sink.binding.yaml b/generic-examples/kamelets/timer-source-log-sink/log-sink.pipe.yaml similarity index 91% rename from generic-examples/kamelets/timer-source-log-sink/log-sink.binding.yaml rename to generic-examples/kamelets/timer-source-log-sink/log-sink.pipe.yaml index 648d9f8..bd07d14 100644 --- a/generic-examples/kamelets/timer-source-log-sink/log-sink.binding.yaml +++ b/generic-examples/kamelets/timer-source-log-sink/log-sink.pipe.yaml @@ -15,8 +15,8 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding +apiVersion: camel.apache.org/v1 +kind: Pipe metadata: name: log-event-sink spec: @@ -28,5 +28,5 @@ spec: sink: ref: kind: Kamelet - apiVersion: camel.apache.org/v1alpha1 + apiVersion: camel.apache.org/v1 name: log-sink diff --git a/generic-examples/kamelets/timer-source-log-sink/readme.md b/generic-examples/kamelets/timer-source-log-sink/readme.md index 3948acd..af3b7f3 100644 --- a/generic-examples/kamelets/timer-source-log-sink/readme.md +++ b/generic-examples/kamelets/timer-source-log-sink/readme.md @@ -3,6 +3,7 @@ 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. ## Additional requirement for running this example + - You should have Knative properly installed on your cluster ([see installation guide](https://knative.dev/docs/install/)) ## Create events source and sink @@ -15,11 +16,11 @@ $ kubectl apply -f log-sink.kamelet.yaml You can check the newly created `kamelet`s in the list. ``` -$ kubectl get kamelets +$ kubectl get kamelets timer-source log-sink NAME PHASE -log-sink Ready timer-source Ready +log-sink Ready ``` ## Create channel destination @@ -31,17 +32,17 @@ $ 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. +We can now bind the timer event source to produce events on the destination with the `timer-source.pipe.yaml` configuration. ``` -$ kubectl apply -f timer-source.binding.yaml +$ kubectl apply -f timer-source.pipe.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. +In a similar fashion you can bind to the log sink in order to consume those events with the `log-sink.pipe.yaml` configuration. ``` -$ kubectl apply -f log-sink.binding.yaml +$ kubectl apply -f log-sink.pipe.yaml ``` -You can check the newly created bindings listing the `KameletBidings`. +You can check the newly created bindings listing the `Pipes`. ``` -$ kubectl get KameletBindings +$ kubectl get Pipes NAME PHASE log-event-sink Ready diff --git a/generic-examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml b/generic-examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml index 1bc4304..3ccbaf4 100644 --- a/generic-examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml +++ b/generic-examples/kamelets/timer-source-log-sink/timer-source.kamelet.yaml @@ -15,7 +15,7 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 +apiVersion: camel.apache.org/v1 kind: Kamelet metadata: name: timer-source diff --git a/generic-examples/kamelets/timer-source-log-sink/timer-source.binding.yaml b/generic-examples/kamelets/timer-source-log-sink/timer-source.pipe.yaml similarity index 92% rename from generic-examples/kamelets/timer-source-log-sink/timer-source.binding.yaml rename to generic-examples/kamelets/timer-source-log-sink/timer-source.pipe.yaml index 73848db..0d1144f 100644 --- a/generic-examples/kamelets/timer-source-log-sink/timer-source.binding.yaml +++ b/generic-examples/kamelets/timer-source-log-sink/timer-source.pipe.yaml @@ -15,15 +15,15 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding +apiVersion: camel.apache.org/v1 +kind: Pipe metadata: name: timer-event-source spec: source: ref: kind: Kamelet - apiVersion: camel.apache.org/v1alpha1 + apiVersion: camel.apache.org/v1 name: timer-source properties: message: "Hello world!" diff --git a/generic-examples/kamelets/timer-source/kamelet-binding-example.yaml b/generic-examples/kamelets/timer-source/kamelet-pipe-example.yaml similarity index 92% rename from generic-examples/kamelets/timer-source/kamelet-binding-example.yaml rename to generic-examples/kamelets/timer-source/kamelet-pipe-example.yaml index 4526775..0bfb8f8 100644 --- a/generic-examples/kamelets/timer-source/kamelet-binding-example.yaml +++ b/generic-examples/kamelets/timer-source/kamelet-pipe-example.yaml @@ -15,15 +15,15 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 -kind: KameletBinding +apiVersion: camel.apache.org/v1 +kind: Pipe metadata: name: timer-source spec: source: ref: kind: Kamelet - apiVersion: camel.apache.org/v1alpha1 + apiVersion: camel.apache.org/v1 name: timer-source properties: message: "Hello world!" diff --git a/generic-examples/kamelets/timer-source/readme.md b/generic-examples/kamelets/timer-source/readme.md index 8124f70..f77f0f5 100644 --- a/generic-examples/kamelets/timer-source/readme.md +++ b/generic-examples/kamelets/timer-source/readme.md @@ -1,29 +1,29 @@ # 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`. +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 `Pipe`. ## 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 +$ kubectl get kamelet timer-source 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: + +As soon as the `kamelet` is available in your cluster, you can use it in any integration such as the one defined in `usage.yaml` file: + ``` -$ kamel run usage.groovy +$ kamel run usage.yaml ``` You should be able to see the new integration running after some time: ``` @@ -45,20 +45,22 @@ $ kamel log usage [1] 2022-08-20 08:21:02,928 INFO [route1] (Camel (camel-1) thread #1 - 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 +$ 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: +Once the destination is ready, you can reference it from a `Pipe` such as in the example `kamelet-pipe-example.yaml`. In order to bind the connector to the destination apply the configuration: ``` -$ kubectl apply -f kamelet-binding-example.yaml +$ kubectl apply -f kamelet-pipe-example.yaml ``` You can confirm the creation of the `KameletBinding` listing the resources: ``` -$ kubectl get kameletbindings +$ kubectl get pipes NAME PHASE timer-source Ready diff --git a/generic-examples/kamelets/timer-source/timer-source.kamelet.yaml b/generic-examples/kamelets/timer-source/timer-source.kamelet.yaml index 1bc4304..3ccbaf4 100644 --- a/generic-examples/kamelets/timer-source/timer-source.kamelet.yaml +++ b/generic-examples/kamelets/timer-source/timer-source.kamelet.yaml @@ -15,7 +15,7 @@ # limitations under the License. # --------------------------------------------------------------------------- -apiVersion: camel.apache.org/v1alpha1 +apiVersion: camel.apache.org/v1 kind: Kamelet metadata: name: timer-source diff --git a/generic-examples/kamelets/timer-source/usage.groovy b/generic-examples/kamelets/timer-source/usage.groovy deleted file mode 100755 index 8528998..0000000 --- a/generic-examples/kamelets/timer-source/usage.groovy +++ /dev/null @@ -1,21 +0,0 @@ -// camel-k: language=groovy - -/* - * 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. - */ - -from('kamelet:timer-source?message=Hello+Kamelets&period=1000') - .log('${body}') diff --git a/generic-examples/kamelets/timer-source/usage.yaml b/generic-examples/kamelets/timer-source/usage.yaml new file mode 100755 index 0000000..70a4358 --- /dev/null +++ b/generic-examples/kamelets/timer-source/usage.yaml @@ -0,0 +1,23 @@ +# camel-k: language=yaml + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "kamelet:timer-source?message=Hello+Kamelets&period=1000" + steps: + - to: "log:info" diff --git a/generic-examples/knative/README.md b/generic-examples/knative/README.md index d677134..598fe49 100644 --- a/generic-examples/knative/README.md +++ b/generic-examples/knative/README.md @@ -107,7 +107,7 @@ If you've installed all the services, you'll find that the printer pod will prin If you now stop the feed integration (`kamel delete feed`) you will notice that the other services (splitter and printer) will scale down to 0 in few minutes. -And if you reinstall the feed again (`kamel run feed.groovy`), the other integration will scale up again as soon as they receive messages (splitter first, then printer). +And if you reinstall the feed again (`kamel run feed.yaml`), the other integration will scale up again as soon as they receive messages (splitter first, then printer). ## Playing harder diff --git a/generic-examples/languages/routes.yaml b/generic-examples/languages/routes.yaml index 201b47a..fe3eb83 100644 --- a/generic-examples/languages/routes.yaml +++ b/generic-examples/languages/routes.yaml @@ -1,3 +1,5 @@ +# camel-k: language=yaml + # --------------------------------------------------------------------------- # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with diff --git a/generic-examples/master/Master.java b/generic-examples/master/Master.java deleted file mode 100755 index fa9e743..0000000 --- a/generic-examples/master/Master.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ - -// camel-k: language=java - -import org.apache.camel.builder.RouteBuilder; - -/** - * This example shows how to start a route on a single instance of the integration. - * Increase the number of replicas to see it in action (the route will be started on a single pod only). - */ -public class Master extends RouteBuilder { - @Override - public void configure() throws Exception { - - // Write your routes here, for example: - from("master:lock:timer:master?period=1000") - .setBody() - .simple("This message is printed by a single pod, even if you increase the number of replicas!") - .to("log:info"); - - } -} diff --git a/generic-examples/master/README.md b/generic-examples/master/README.md index a79f111..ff56683 100644 --- a/generic-examples/master/README.md +++ b/generic-examples/master/README.md @@ -8,11 +8,11 @@ You can find more information about Apache Camel and Apache Camel K on the [offi 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. +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. ## Understanding the Example -- [Master.java](./Master.java): defines a route that will be started only on a single instance/pod. This is defined by prefixing the camel endpoint with `master:someName`. + +- [master.yaml](./master.yaml): defines a route that will be started only on a single instance/pod. This is defined by prefixing the camel endpoint with `master:someName`. Under the hood, the pod replicas take part in a leader election where each pod races to become the leader. The pod that emerges as leader will be the only instance that is active and consumes from the specified camel endpoint. If the leader fails, another pod becomes the new leader, thus becoming the only instance that consumes from the camel endpoint. ## Running the example @@ -20,12 +20,12 @@ Under the hood, the pod replicas take part in a leader election where each pod r Run the integration: ``` -kamel run Master.java +$ kamel run master.yaml ``` In this example, we will use the [stern](https://github.com/stern/stern) CLI tool to view the logs because it allows us to view multiple pod logs at the same time.
Since only a single instance is created, that becomes the leader and logs the routed message: _"This message is printed by a single pod, even if you increase the number of replicas!"_. ``` -stern master +$ stern master ``` ``` ... @@ -40,8 +40,9 @@ master-6f8df78d54-lbnwp integration 2022-09-11 18:38:03,641 INFO [info] (Camel Increase the number of replicas: ``` -kubectl scale it master --replicas 3 +$ kubectl scale it master --replicas 3 ``` + Still looking at the logs from `stern master` we see that although more instances have been created, the routed message is still being logged by the leader pod alone. ``` @@ -56,7 +57,7 @@ In the event that the leader fails, the other instances race to become the new l Kill the leader pod: ``` -kubectl delete pod +$ kubectl delete pod ``` Looking at the logs from `stern master`, we see the other pod replicas attempt to become the new leader. Later, a new leader emerges that carries out the function of printing the message: ``` diff --git a/generic-examples/master/master.yaml b/generic-examples/master/master.yaml new file mode 100644 index 0000000..ba17898 --- /dev/null +++ b/generic-examples/master/master.yaml @@ -0,0 +1,25 @@ +# camel-k: language=yaml + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "master:lock:timer:master?period=1000" + steps: + - set-body: + constant: "This message is printed by a single pod, even if you increase the number of replicas!" + - to: "log:info" diff --git a/generic-examples/olm/README.md b/generic-examples/olm/README.md deleted file mode 100644 index 8a0977e..0000000 --- a/generic-examples/olm/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# OPERATOR Lifecycle manager (OLM) installation - -Camel K supports as default an installation procedure in order to get all the features offered by [OLM](https://olm.operatorframework.io/). We have in place a default mechanism to discover the presence of OLM installed on your cluster. - -NOTE: You can disable the feature by providing the `--olm=false` during the installation procedure. - -## Install on Minikube - -An interesting way to test locally the OLM is to use the **Minikube OLM addon**. If you have a local Minikube, you can proceed with the following steps to install the OLM: - -``` -minikube addons enable olm -``` - -As soon as all the resources are installed, you can now proceed by installing Camel K operator as you used to do, ie: - -``` -kamel install --global -``` - -In order to verify the installation, you can check the `ClusterServiceVersion` (CSV) custom resource: - -``` -kubectl get csv -NAME DISPLAY VERSION REPLACES PHASE -camel-k-operator.v1.8.2 Camel K Operator 1.8.2 camel-k-operator.v1.8.1 Succeeded -``` - -You can now run any integration as you used to do. \ No newline at end of file diff --git a/generic-examples/polyglot/README.md b/generic-examples/polyglot/README.md index 07072cf..5d4cd82 100644 --- a/generic-examples/polyglot/README.md +++ b/generic-examples/polyglot/README.md @@ -3,5 +3,5 @@ Run an integration using different Camel DSL languages. ``` -$ kamel run --name polyglot routes.xml beans.groovy JavaRoute.java +$ kamel run --name polyglot --dev routes.yaml beans.groovy JavaRoute.java ``` \ No newline at end of file diff --git a/generic-examples/polyglot/routes.xml b/generic-examples/polyglot/routes.xml deleted file mode 100644 index 6e170ac..0000000 --- a/generic-examples/polyglot/routes.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - diff --git a/generic-examples/polyglot/routes.yaml b/generic-examples/polyglot/routes.yaml new file mode 100644 index 0000000..c9127af --- /dev/null +++ b/generic-examples/polyglot/routes.yaml @@ -0,0 +1,27 @@ +# camel-k: language=yaml + +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +- from: + uri: "timer:hello?period=3000" + steps: + - process: + ref: "javaProcessor" + - process: + ref: "groovyProcessor" + - to: "log:info?showAll=true&multiline=true"