Skip to content

Commit

Permalink
fix(doc): Remove ambiguous local files usage on config/resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer authored and squakez committed Oct 30, 2023
1 parent 81bd068 commit 3d1fa45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/configuration/runtime-config.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[[runtime-config]]
= Runtime configuration

When you develop an integration with `Camel K` there are many ways you can provide a *configuration* resource to the runtime `Integration`. The most familiar way is to handle local file, but since we are dealing with `Kubernetes` you may need also to use `Configmap` or `Secret`. The `kamel run` command is provided with a `--config` flag that help you setting any configuration resource your `Integration` need.
When you develop an integration with `Camel K` there are many ways you can provide a *configuration* resource to the runtime `Integration`. Since we are dealing with `Kubernetes` we use `Configmap` or `Secret`. The `kamel run` command is provided with a `--config` flag that help you setting any configuration resource your `Integration` need.

The *runtime configuration* files are expected to be encoded in `UTF-8` as they are processed by runtime `Camel Context` and parsed as property files. These resources are materialized as files in a well known path in the `Integration` `Pod`. They are also made available on the classpath in order to ease their usage directly from the `Route`. If you need to provide a non `UTF-8` (ie, a binary resource) you may look for `--resource` flag instead.
The *runtime configuration* are expected to be encoded in `UTF-8` as they are processed by runtime `Camel Context` and parsed as property files. These resources are materialized as files in a well known path in the `Integration` `Pod`. The `mount` trait will be declared on the `Integration`. They are also made available on the classpath in order to ease their usage directly from the `Route`. If you need to provide a non `UTF-8` (ie, a binary resource) you may look for `--resource` flag instead.

NOTE: the scope of `--config` global option had different meaning prior Camel K version 1.5. The old global `--config` has been replaced with `--kube-config` since Camel K version 1.5.

Expand Down Expand Up @@ -130,7 +130,7 @@ Let's use the _key_ filtering:
kamel run --config secret:my-sec-multi/my-secret-key-2 config-secret-key-route.groovy
----

You may check in the `Integration` `Pod` that only the _my-secret-key-2_ file has been mounted.
You may check in the `Integration` `Pod` that only the _my-secret-key-2_ data has been mounted.

[[runtime-config-resources]]
== Runtime resources
Expand Down
17 changes: 12 additions & 5 deletions docs/modules/ROOT/pages/configuration/runtime-resources.adoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[[runtime-resources]]
= Runtime resources

When you develop an integration with `Camel K` there are many ways you can provide a *resource* to the runtime `Integration`. The most familiar way is to handle local file, but since we are dealing with `Kubernetes` you may need also to use `Configmap` or `Secret`. The `kamel run` command is provided with a `--resource` flag that help you setting any resource your `Integration` may need.
When you develop an integration with `Camel K` there are many ways you can provide a *resource* to the runtime `Integration`. Since we are dealing with `Kubernetes` we use `Configmap` or `Secret`. The `kamel run` command is provided with a `--resource` flag that help you setting any resource your `Integration` may need.

The *runtime resources* are expected to be any resource type (text or binary content). These resources are materialized as files in the `Integration` `Pod`. The destination path can be either a default location or any path specified by the user. Only default resource directory is available within the `Integration` classpath.
The *runtime resources* are expected to be any resource type (text or binary content). These resources are materialized as files in the `Integration` `Pod`. The `mount` trait will be declared on the `Integration`. The destination path can be either a default location or any path specified by the user. Only default resource directory is available within the `Integration` classpath.

NOTE: you'll find `--resource` is very similar to the `--config` run flag. The main difference is that a `resource` can have a binary content and it won't be parsed by the Camel Context.

Expand Down Expand Up @@ -72,22 +72,29 @@ NOTE: you can provide a `Secret` which is not yet available on the cluster. The

When you are programming an `Integration` you may find yourself in the situation to specify where exactly a resource has to be mounted. For such purpose you can specify the location where a file is expected with the `--resource` _@path_ syntax.

As an example, let's create a `Configmap` named _my-cm_ containing certain information. You can alternatively use any `Configmap` you've already stored in your cluster:

----
kubectl create configmap my-cm-files --from-literal=input.txt="configmap input.txt content"
----


Let's see an example where your integration expect a text file to be consumed under a specific filesystem location:

[source,groovy]
.resource-file-location-route.groovy
----
from('file:/tmp/?fileName=input.txt&noop=true&idempotent=false')
from('file:/tmp/inputs/?fileName=input.txt&noop=true&idempotent=false')
.log('resource file content is: ${body}')
----

When running the `Integration`, you can specify where to mount the resource content (either a `File`, `Configmap` or `Secret`) with the _@path_ syntax:

----
kamel run --resource configmap:my-cm@/tmp/input.txt resource-file-location-route.groovy
kamel run --resource configmap:my-cm-files@/tmp/inputs resource-file-location-route.groovy
----

You may check in the `Integration` `Pod` and verify that the file was mounted in the _tmp/input.txt_ destination.
You may check in the `Integration` `Pod` and verify that the file was mounted in the _tmp/inputs/input.txt_ destination.

[[runtime-resource-keys]]
== Configmap/Secret key filtering
Expand Down

0 comments on commit 3d1fa45

Please sign in to comment.