This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 1f0431ec9c6ebfad58ac532cb34986802f62bf2e Author: Pasquale Congiusti <pasquale.congiu...@gmail.com> AuthorDate: Wed Aug 18 12:45:27 2021 +0200 doc(kamelets): trait annotation Closes #2500 --- .../modules/ROOT/pages/kamelets/kamelets-user.adoc | 28 +++++++++++++++++++++ examples/kamelets/kameletbindings/README.md | 3 +++ .../kameletbindings/kb-trait-annotation.yaml | 29 ++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/docs/modules/ROOT/pages/kamelets/kamelets-user.adoc b/docs/modules/ROOT/pages/kamelets/kamelets-user.adoc index 6e42174..500b039 100644 --- a/docs/modules/ROOT/pages/kamelets/kamelets-user.adoc +++ b/docs/modules/ROOT/pages/kamelets/kamelets-user.adoc @@ -360,6 +360,29 @@ To comply with the Knative specifications, in case an "http" or "https" URI is u You can configure an error handler in order to specify what to do when some event ends up with failure. See xref:kamelets/kameletbindings-error-handler.adoc[Kamelet Bindings Error Handler User Guide] for more detail. +=== Trait via annotations + +You can easily tune your `KameletBinding` with xref:traits:traits.adoc[traits] configuration adding `.metadata.annotations`. Let's have a look at the following example: + +[source,yaml] +---- +apiVersion: camel.apache.org/v1alpha1 +kind: KameletBinding +metadata: + name: timer-2-log-annotation + annotations: # <1> + trait.camel.apache.org/logging.level: DEBUG + trait.camel.apache.org/logging.color: "false" +spec: + source: + uri: timer:foo + sink: + uri: log:bar +---- +<1> Include `.metadata.annotations` to specify the list of traits we want to configure + +In this example, we've set the `logging` trait to specify certain configuration we want to apply. You can do the same with all the traits available, just by setting `trait.camel.apache.org/trait-name.trait-property` with the expected value. + [[kamelets-troubleshooting]] == Troubleshooting @@ -400,6 +423,11 @@ The following annotations and labels are also defined on the resource: |An optional icon for the Kamelet in URI data format |`string` |E.g. `data:image/svg+xml;base64,PD94bW...` + +|`trait.camel.apache.org/trait-name.trait-property` +|An optional configuration setting for a trait +|`string` +|E.g. `trait.camel.apache.org/logging.level: DEBUG` |=== .Labels diff --git a/examples/kamelets/kameletbindings/README.md b/examples/kamelets/kameletbindings/README.md new file mode 100644 index 0000000..9e2ba04 --- /dev/null +++ b/examples/kamelets/kameletbindings/README.md @@ -0,0 +1,3 @@ +# KameletBindings examples + +Find useful examples about how to use KameletBindings. diff --git a/examples/kamelets/kameletbindings/kb-trait-annotation.yaml b/examples/kamelets/kameletbindings/kb-trait-annotation.yaml new file mode 100644 index 0000000..73a5d6a --- /dev/null +++ b/examples/kamelets/kameletbindings/kb-trait-annotation.yaml @@ -0,0 +1,29 @@ +# --------------------------------------------------------------------------- +# 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-2-log-annotation + annotations: + trait.camel.apache.org/logging.level: DEBUG + trait.camel.apache.org/logging.color: "false" +spec: + source: + uri: timer:foo + sink: + uri: log:bar \ No newline at end of file