nicolaferraro opened a new pull request #1602:
URL: https://github.com/apache/camel-k/pull/1602
<!-- Description -->
This adds Kamelets to the operator. They belong to the `v1alpha1` API
version, since their structure is expected to change as we have more ideas
about them.
A Kamelet currently looks like:
```yaml
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: timer
annotations:
camel.apache.org/kamelet.icon: timer
spec:
definition:
title: "Timer"
description: "Produces periodic events with a custom payload"
required:
- message
properties:
message:
title: Message
description: The message to generate
type: string
types:
out:
mediaType: application/json
schema:
id: text.camel.apache.org
type: string
flow:
from:
uri: timer:tick
steps:
- set-body:
constant: "Hello [here there'll be the message, but we need to
define how to pass it in runtime] !!!"
- to: "log:info"
```
People can use the kamelet as in:
```groovy
from('kamelet:timer')
.to('log:info')
```
But currently the `kamelet` component does not exist in runtime, so it would
fail.
The user can optionally use a predefined configuration for the Kamelet:
```groovy
from('kamelet:timer/mytimer')
.to('log:info')
```
In this case, all secrets labelled with `camel.apache.org/kamelet=timer` and
`camel.apache.org/kamelet.configuration=mytimer` will be loaded automatically
into the context. Properties inside the secret are expected to reference the
`mytimer` kamelet (in a way that the runtime will define).
Secrets with `camel.apache.org/kamelet=timer` and no configuration label
will be also loaded into the context, to provide fallback configuration.
This mechanisms serves to create "instances" of a Kamelet, by providing a
specific configuration (somewhere else called "connection") and will be useful
for setting e.g. addresses and tokens for external systems.
Once used in an integration, a kamelet will be loaded under
`/etc/camel/kamelets.d/{name}/`.
The dir will contain two files for each Kamelet:
- {name}.yaml (or another extension): contains the Kamelet route
- {name}-schema.json: contains the json schema of the Kamelet configuration
(`spec -> definition` field, converted into JSON)
All those files are also referenced in the default application.properties
file. E.g. for timer:
*application.properties*
```
camel.k.kamelets[timer].schema=/etc/camel/kamelets.d/timer/timer-schema.json
camel.k.kamelets[timer].language=yaml
camel.k.kamelets[timer].location=file:/etc/camel/kamelets.d/timer/timer.yaml
```
All other source options (e.g. compression, loader, interceptors) are also
set as children of `camel.k.kamelets[{name}]`.
<!--
Enter your extended release note in the below block. If the PR requires
additional action from users switching to the new release, include the string
"action required". If no release note is required, write "NONE".
You can (optionally) mark this PR with labels "kind/bug" or "kind/feature"
to make sure
the text is added to the right section of the release notes.
-->
**Release Note**
```release-note
Kamelets (v1alpha1) have been added as new way to define reusable route
fragments
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]