Skip to content

Commit

Permalink
chore(doc): kamelets deployment explained
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Oct 5, 2023
1 parent db15054 commit 5e60f50
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 36 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav-end.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
*** xref:architecture/cr/camel-catalog.adoc[CamelCatalog]
** xref:architecture/runtime.adoc[Runtime]
** xref:architecture/traits.adoc[Traits]
** xref:architecture/kamelets.adoc[Kamelets]
** xref:architecture/incremental-image.adoc[Incremental Image]
* API
** xref:apis/camel-k.adoc[Camel K API]
Expand Down
13 changes: 13 additions & 0 deletions docs/modules/ROOT/pages/architecture/kamelets.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
= Kamelets architecture in Camel K

xref:kamelets/kamelets.adoc[Kamelets] are a technology which were originally developed as a Camel K side resource but moved into Camel framework as Kamelet component. From an design point of view, a Kamelet is a specification that is provided into the cluster and which can be used at any point by an Integration or a Pipe, in order to reuse the connector style approach.

In Camel framework, a Kamelet is nothing than a component which can be used as any other component with the `kamelet` uri scheme. This is translated to one or more Route Templates. What's important for Camel runtime is to have the Kamelet spec available somewhere when running the application making reference to it.

== Deployment model

In Camel K, it is worth to explain how the Kamelets are deployed in order to make Camel runtime application to correctly use the Kamelet referenced in the Integration. First of all, the operator uses a xref:traits:kamelets.adoc[Camel K trait] which is in charge to discover the Kamelets used in your route. This is due to get all the specification and dependencies required.

image::architecture/kamelets_deployment.png[Kamelets deployment model]

The operator creates a Configmap in order to bundle all the Kamelets which are eventually required by the application runtime. The Kamelets spec has to be available and in ready phase status. Once the application is created and ready to start, the operator mounts such a Configmap in a known location (default `/etc/camel/kamelets`) so that the Camel application will be able to read the definition from such location and run them according the logic expected in the same Camel framework.
11 changes: 10 additions & 1 deletion docs/modules/ROOT/pages/kamelets/kamelets-distribution.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ kamel kamelet add-repo <git-platform>:<owner>/<repo>[/path_to_kamelets_folder][@
```
Mind that `<git-platform>` is the repository of your choice, for instance `github` and `[@version]` is the tag to use (by default it will use `main` branch).

With this approach you can dynamically include any repository where your Kamelets are hosted. They will be lazily initialized as soon as they are required by any of the Integration or Pipes which will make use of them.
With this approach you can dynamically include any repository where your Kamelets are hosted. They will be lazily initialized as soon as they are required by any of the Integration or Pipes which will make use of them.

[[kamelets-as-dependency]]
== Kamelets as a dependency

The Camel K has an opinionated way to use Kamelets which is the one exposed above. Here the Kamelet spec resource is expected to be available in the cluster.

However, you may find situations where you want to bundle a Kamelet in a dependency (ie, some external catalog containing all Kamelets spec). As Kamelets are a Camel thing, then, you can use such dependency and let the runtime use the Kamelets available in the classpath.

If you're using such an approach, then, you will need to make sure to skip the Kamelet trait (which is in charge to discover them and get required dependencies), and provide all the dependencies which may be required by your Kamelet. Additionally, you may need to specify a Camel property to tell the runtime where to expect to find the Kamelets, `camel.component.kamelet.location` (default `classpath:/kamelets`).
29 changes: 0 additions & 29 deletions docs/modules/ROOT/pages/kamelets/kamelets-user.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -205,35 +205,6 @@ from('timer:tick')
You can run this integration without specifying other parameters, the Kamelet endpoint will be implicitly configured by the Camel K operator that will
automatically mount the secret into the integration Pod.

[[kamelets-default-catalog]]
== Kamelets Catalog

When you install a Camel K Operator, you will have automatically a wide set of canned Kamelets available to be used. The catalog and the related documentation is available at link:/camel-kamelets/next/index.html[Apache Kamelets Catalog]. There is a CLI command very useful to have a quick list of the available Kamelets:
[source,shell]
----
$ kamel kamelet get
----

These Kamelets are installed by default when you install Camel K operator. You will be able to use them without worrying to install each of them, just look at the documentation and be ready to experiment how easy they are.

[[kamelets-custom-catalog]]
=== Use a custom Catalog

You can overwrite the default catalog by adding certain configuration to the `IntegrationPlatform`. In order to add a new repository, you must edit the `IntegrationPlatfom` and edit the `.spec.kamelet.repositories[].uri` field, which expects an array of repository URIs where you can host your catalog of Kamelets, ie:
[source,yaml]
----
spec:
...
kamelet:
repositories:
- uri: github:my-org/my-repo
...
----

By default the value is null, which means they fallback to the Apache Kamelets Catalog.

NOTE: this option is experimental and may be subjected to changes in future versions.

[[kamelets-usage-binding]]
== Binding Kamelets

Expand Down
8 changes: 2 additions & 6 deletions pkg/trait/kamelets.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ func newConfigurationKey(kamelet, configurationID string) configurationKey {
}

const (
contentKey = "content"

kameletLabel = "camel.apache.org/kamelet"
kameletConfigurationLabel = "camel.apache.org/kamelet.configuration"
)
Expand Down Expand Up @@ -177,7 +175,6 @@ func (t *kameletsTrait) addKamelets(e *Environment) error {
return err
}

immutable := true
kameletConfigmap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",
Expand All @@ -194,8 +191,7 @@ func (t *kameletsTrait) addKamelets(e *Environment) error {
"camel.apache.org/generated": "true",
},
},
Data: map[string]string{},
Immutable: &immutable,
Data: map[string]string{},
}

for _, key := range t.getKameletKeys() {
Expand Down Expand Up @@ -240,7 +236,7 @@ func addKamelet(kamelet *v1.Kamelet, kameletBundle *corev1.ConfigMap) error {
// kubectl create secret generic my-company-log-sink.mynamedconfig --from-file=mynamedconfig.properties
// kubectl label secret my-company-log-sink.mynamedconfig camel.apache.org/kamelet=my-company-log-sink camel.apache.org/kamelet.configuration=mynamedconfig
//
// then, this func is in charge to add such a secret to the Integration
// then, this func is in charge to add such a secret to the Integration.
func (t *kameletsTrait) addConfigurationSecrets(e *Environment) error {
for _, k := range t.getConfigurationKeys() {
options := metav1.ListOptions{
Expand Down

0 comments on commit 5e60f50

Please sign in to comment.