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 10, 2023
1 parent cd65373 commit 2b5e3f6
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 77 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
19 changes: 19 additions & 0 deletions docs/modules/ROOT/pages/architecture/kamelets.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
= 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]]
== 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.

[[kamelet-parsing]]
=== Parsing capabilities defined in a Kamelet

The operator is in charge to perform one important hidden operation. The Kamelet specification may contains Camel components and capabilities which the user should be in charge to define explicitly. However, the operator extract the Kamelet source and parses its content as a generated Integration source. In this way you will be able to get all the Kubernetes resources which are required to run your Integration (ie, a Kamelet using rest or exposing http services).
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
15 changes: 14 additions & 1 deletion pkg/apis/camel/v1/common_types_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,20 @@ func DecodeValueSource(input string, defaultKey string, errorMessage string) (Va
return ValueSource{}, fmt.Errorf(errorMessage)
}

// IsGeneratedFromKamelet determines is a source spec is derived from a Kamelet
// IsGeneratedFromKamelet determines is a source spec is derived from a Kamelet.
func (s *SourceSpec) IsGeneratedFromKamelet() bool {
return s.FromKamelet
}

// InferLanguage returns the language of the source or discovers it from file extension if not set.
func (s *SourceSpec) InferLanguage() Language {
if s.Language != "" {
return s.Language
}
for _, l := range Languages {
if strings.HasSuffix(s.Name, "."+string(l)) {
return l
}
}
return ""
}
13 changes: 0 additions & 13 deletions pkg/apis/camel/v1/integration_types_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,6 @@ func NewSourceSpec(name string, content string, language Language) SourceSpec {
}
}

// InferLanguage returns the language of the source or discovers it from file extension if not set.
func (in *SourceSpec) InferLanguage() Language {
if in.Language != "" {
return in.Language
}
for _, l := range Languages {
if strings.HasSuffix(in.Name, "."+string(l)) {
return l
}
}
return ""
}

// SetOperatorID sets the given operator id as an annotation.
func (in *Integration) SetOperatorID(operatorID string) {
SetAnnotation(&in.ObjectMeta, OperatorIDAnnotation, operatorID)
Expand Down
49 changes: 16 additions & 33 deletions pkg/resources/resources.go

Large diffs are not rendered by default.

0 comments on commit 2b5e3f6

Please sign in to comment.