Traits

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.

Configuration

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.

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 container.service-port=8081 file.groovy

Or the equivalent command (assuming that the service trait is enabled by auto-detection):

kamel run -t container.service-port=8081 file.groovy
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.

Common Traits

The following is a list of common traits that can be configured by the end users:

Trait Profiles Description

dependencies

Kubernetes, OpenShift

Automatically adds dependencies required by the Camel routes by inspecting the user code.

It’s enabled by default.

deployer

Kubernetes, OpenShift

Configure deployer behavior.

It’s enabled by default.

deployer.kind

Allows to explicitly select the desired deployment kind between deployment or knative-service when creating the resources for running the integration.

deployment

Kubernetes, OpenShift

Creates a standard Kubernetes deployment for running the integration.

It’s enabled by default on vanilla Kubernetes/Openshift profiles.

affinity

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.

It’s disabled by default.

affinity.pod-affinity

Always co-locates multiple replicas of the integration in the same node (default false).

affinity.pod-affinity-labels

Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the integration pod(s) should be co-located with.

affinity.pod-anti-affinity

Never co-locates multiple replicas of the integration in the same node (default false).

affinity.pod-anti-affinity-labels

Defines a set of pods (namely those matching the label selector, relative to the given namespace) that the integration pod(s) should not be co-located with.

affinity.node-affinity-labels

Defines a set of nodes the integration pod(s) are eligible to be scheduled on, based on labels on the node.

Examples:

  • To schedule the integration pod(s) on a specific node using the built-in node label kubernetes.io/hostname:

    $ kamel run -t affinity.node-affinity-labels="kubernetes.io/hostname in(node-66-50.hosted.k8s.tld)" ...
  • To schedule a single integration pod per node (using the Exists operator):

    $ kamel run -t affinity.pod-anti-affinity-labels="camel.apache.org/integration" ...
  • To co-locate the integration pod(s) with other integration pod(s):

    $ kamel run -t affinity.pod-affinity-labels="camel.apache.org/integration in(it1, it2)" ...

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.pod-anti-affinity-labels="camel.apache.org/integration" -t affinity.pod-anti-affinity-labels="camel.apache.org/component=operator" ...

More information can be found in the official Kubernetes documentation about Assigning Pods to Nodes.

knative

Knative (Kubernetes, OpenShift)

Creates Knative resources to run the integration instead of the standard Kubernetes resources.

It’s enabled by default when the Knative profile is active.

knative.channel-sources

Configures a (comma-separated) list of channels to which the Knative service must be subscribed (to receive cloudevents from a channel). May also contain Camel URIs instead of simple names.

knative.channel-sinks

Configures a (comma-separated) list of channels to which the Knative service publishes. May also contain Camel URIs instead of simple names.

knative.endpoint-sources

Configures a (comma-separated) list of endpoints the Knative service exposes (the name is). May also contain Camel URIs instead of simple names.

knative.endpoint-sinks

Configures a (comma-separated) list of endpoints the Knative consumes. May also contain Camel URIs instead of simple names.

knative.event-sources

Configures a (comma-separated) list of events that will trigger the Knative service (receiving cloudevents from the broker). May also contain Camel URIs instead of simple names.

knative.event-sinks

Configures a (comma-separated) list of event types that the service will produce. May also contain Camel URIs instead of simple names.

knative.filter-source-channels

Force the knative endpoint to filter messages based on the ce-knativehistory header (Knative experimental feature). It’s enabled automatically when there are more than 2 source channels. It’s optional (default to false) when there’s a single source channel.

istio

All

Allows to configure outbound traffic for Istio.

It’s disabled by default.

istio.allow

Configures a (comma-separated) list of CIDR subnets that should not be intercepted by the Istio proxy (10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 by default).

istio.inject

Forces the value for labels sidecar.istio.io/inject. By default the label is set to true on deployment and not set on Knative Service.

service

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.

It’s enabled by default if the integration depends on a Camel component that can expose a HTTP endpoint.

route

OpenShift

Exposes the service associated with the integration to the outside world with a OpenShift Route.

It’s enabled by default whenever a Service is added to the integration (through the service trait).

route.host

To configure the host exposed by the route.

ingress

Kubernetes

Exposes the service associated with the integration to the outside world with a Kubernetes Ingress.

It’s enabled by default whenever a Service is added to the integration (through the service trait).

ingress.host

Required. To configure the host exposed by the ingress.

debug

All

Run the integration in debug mode (you can port-forward to port 5005 to connect)

It’s disabled by default.

jolokia

Kubernetes, OpenShift

Activate and configures the Jolokia Java agent.

It’s disabled by default.

jolokia.protocol

The protocol to use, either http or https (default https for OpenShift)

jolokia.host

The Host address to which the Jolokia agent should bind to. If "*" or "0.0.0.0" is given, the servers binds to every network interface (default "*").

jolokia.port

The Jolokia endpoint port (default 8778).

jolokia.user

The user to be used for authentication

jolokia.password

The password used for authentication, applicable when the user option is set

jolokia.discovery-enabled

Listen for multicast requests (default false)

jolokia.use-ssl-client-authentication

Whether client certificates should be used for authentication (default true for OpenShift)

jolokia.ca-cert

The PEM encoded CA certification file path, used to verify client certificates, applicable when protocol is https and use-ssl-client-authentication is true (default /var/run/secrets/kubernetes.io/serviceaccount/ca.crt for OpenShift).

jolokia.client-principal

The principal which must be given in a client certificate to allow access to the Jolokia endpoint, applicable when protocol is https and use-ssl-client-authentication is true (default clientPrincipal=cn=system:master-proxy for OpenShift).

jolokia.extended-client-check

Mandate the client certificate contains a client flag in the extended key usage section, applicable when protocol is https and use-ssl-client-authentication is true (default true for OpenShift).

jolokia.options

A comma-separated list of additional Jolokia options as defined in JVM agent configuration options, e.g.: keystore=…​,executor=…​

prometheus

Kubernetes, OpenShift

Exposes the integration with a Service and a ServiceMonitor resources so that the Prometheus endpoint can be scraped.

Creating the ServiceMonitor resource requires the Prometheus Operator custom resource definition to be installed. You can set service-monitor to false for the Prometheus trait to work without the Prometheus operator.

It’s disabled by default.

prometheus.port

The Prometheus endpoint port (default 9778).

prometheus.service-monitor

Whether a ServiceMonitor resource is created (default true).

prometheus.service-monitor-labels

The ServiceMonitor resource labels, applicable when service-monitor is true.

camel

All

Resolve Camel version

It’s enabled by default.

camel.version

The camel version to use for the integration, it overrides the default version set in the Integration Platform

probes

Kubernetes, OpenShift

Configure Liveness and Readiness probes.

It’s disabled by default.

probes.bind-host

Configures the host on which the probe is exposed (default 0.0.0.0).

probes.bind-port

Configures the port on which the probe is exposed (default 8080).

probes.path

Path to access on the probe ( default /health).

probes.liveness-initial-delay

Number of seconds after the container has started before liveness probes are initiated.

probes.liveness-timeout

Number of seconds after which the probe times out.

probes.liveness-period

How often to perform the probe.

probes.liveness-success-threshold

Minimum consecutive successes for the probe to be considered successful after having failed.

probes.liveness-failure-threshold

Minimum consecutive failures for the probe to be considered failed after having succeeded.

probes.readiness-initial-delay

Number of seconds after the container has started before liveness probes are initiated.

probes.readiness-timeout

Number of seconds after which the probe times out.

probes.readiness-period

How often to perform the probe.

probes.readiness-success-threshold

Minimum consecutive successes for the probe to be considered successful after having failed.

probes.readiness-failure-threshold

Minimum consecutive failures for the probe to be considered failed after having succeeded.

container

All

Configure integration contianer.

It’s disabled by default.

container.request-cpu

The minimum amount of CPU required.

container.request-memory

The minimum amount of memory required.

container.limit-cpu

The maximum amount of CPU required.

container.limit-memory

The maximum amount of memory required.

container.service-port

To configure under which service port the container port is to be exposed (default 80).

container.service-port-name

To configure under which service port name the container port is to be exposed (default http).

container.port

To configure a different port exposed by the container (default 8080).

container.port-name

To configure a different port name for the port exposed by the container (default http).

quarkus

All

Activates the Quarkus runtime

It’s disabled by default.

quarkus.camel-quarkus-version

The Camel Quarkus version to use for the integration

quarkus.quarkus-version

The Quarkus version to use for the integration

Platform Traits (Advanced)

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

owner

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.

It’s enabled by default.

owner.target-annotations

The annotations to be transferred (A comma-separated list of label keys)

owner.target-labels

The labels to be transferred (A comma-separated list of label keys)

gc

All

Garbage collect resources that are no longer necessary upon integration updates.

It’s enabled by default.