Traits are high level named features of Camel K that can be enabled/disabled or configured to customize the behavior of the final integration.
Camel K provide sensible defaults for all such traits, taking into account the details of the target platform where the integration is going to run into. However, it’s possible for a expert user to configure them in order to obtain a different behavior.
Each trait has a unique ID that can be used to configure it using the command line tool.
E.g. in order to disable the creation of a Service for a integration, a user can execute:
kamel run --trait service.enabled=false file.groovy
--trait can be also abbreviated with
enabled property is available on all traits and can be used to enable/disable them. All traits have their own internal logic to determine if they need to be enabled when the user does not activate them explicitly.
Some traits share also a
auto property that can be used to enable/disable auto-configuration of the trait based on the environment. The auto-configuration mechanism is able to enable/disable the trait when the
enabled property is not explicitly set by the user and also change the trait configuration.
|Some traits are applicable only to specific platforms (see the "profiles" in the trait description page).|
A trait may have additional properties that can be configured by the end user.
Let’s use a further example to show how to configure a trait in an
Integration. If you want to set an additional
JVM classpath pointing to a known dependency, we can use the CLI as we’ve seen above:
$ kamel run --trait jvm.classpath=/path/to/my.jar MyIntegration.java
The command is creating an
Integration with the configuration below:
apiVersion: camel.apache.org/v1 kind: Integration metadata: name: my-integration spec: traits: jvm: configuration: classpath: /path/to/my.jar ...
.spec.traits holds an array of traits, identified by their id (
jvm, in this case). Then, the
.jvm.configuration.classpath is the property we want to set. If you need to set a trait directly in the
Integration spec, then, you should proceed in the way illustrated above.
There are 44 traits. See each trait description page for more information on a specific trait: