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
The flag --trait
can be also abbreviated with -t
.
The 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.
All 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. The auto
property is enabled by default.
Note
|
Some traits are applicable only to specific platforms (see "profiles" in the table). |
A trait may have additional properties that can be configured by the end user.
E.g. the following command configures the container port
that should be exposed by the service:
kamel run --trait service.enabled=true --trait service.port=8081 file.groovy
Or the equivalent command (assuming that the service trait is enabled by auto-detection):
kamel run -t service.port=8081 file.groovy
Note
|
Enabling a trait does not force the trait to be activated, especially if the trait specific preconditions do not hold.
E.g. enabling the route trait while the service trait is disabled does not produce automatically a route, since a service is needed
for the route trait to work.
|
The following is a list of common traits that can be configured by the end users:
Trait | Profiles | Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Kubernetes, OpenShift |
Automatically adds dependencies required by the Camel routes by inspecting the user code.
|
||||||||||||||||||||||
|
Kubernetes, OpenShift |
Configure deployer behavior.
|
||||||||||||||||||||||
|
Kubernetes, OpenShift |
Creates a standard Kubernetes deployment for running the integration.
|
||||||||||||||||||||||
|
All |
Allows to constrain which nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node, or with inter-pod affinity and anti-affinity, based on labels on pods that are already running on the nodes.
Examples:
The labels options follow the requirements from Label selectors. They can be multi-valuated, then the requirements list is ANDed, e.g., to schedule a single integration pod per node AND not co-located with the Camel K operator pod(s): $ kamel run -t affinity.node-anti-affinity-labels="camel.apache.org/integration" -t affinity.node-anti-affinity-labels="camel.apache.org/component=operator" ... More information can be found in the official Kubernetes documentation about Assigning Pods to Nodes. |
||||||||||||||||||||||
|
Knative (Kubernetes, OpenShift) |
Creates Knative resources to run the integration instead of the standard Kubernetes resources.
|
||||||||||||||||||||||
|
Knative (Kubernetes, OpenShift) |
Allows to configure outbound traffic for Istio.
|
||||||||||||||||||||||
|
All (Knative in deployment mode) |
Exposes the integration with a Service resource so that it can be accessed by other applications (or integrations) in the same namespace.
|
||||||||||||||||||||||
|
OpenShift |
Exposes the service associated with the integration to the outside world with a OpenShift Route.
|
||||||||||||||||||||||
|
Kubernetes |
Exposes the service associated with the integration to the outside world with a Kubernetes Ingress.
|
||||||||||||||||||||||
|
All |
Run the integration in debug mode (you can port-forward to port 5005 to connect)
|
||||||||||||||||||||||
|
Kubernetes, OpenShift |
Activate and configures the Jolokia Java agent.
|
||||||||||||||||||||||
|
Kubernetes, OpenShift |
Exposes the integration with a
It’s disabled by default.
|
||||||||||||||||||||||
|
All |
Resolve Camel version
|
There are also platform traits that normally should not be configured by the end user. So change them only if you know what you’re doing.
Trait | Profiles | Description | ||||
---|---|---|---|---|---|---|
|
All |
Ensures that all created resources belong to the integration being created (so they are deleted when the integration is deleted) and transfers annotations and labels on the integration onto these owned resources.
|
||||
|
All |
Garbage collect resources that are no longer necessary upon integration updates.
|