Chapter 6. Camel K trait configuration reference


This chapter provides reference information about advanced features and core capabilities that you can configure on the command line at runtime using traits. Camel K provides feature traits to configure specific features and technologies. Camel K provides platform traits to configure internal Camel K core capabilities.

Important

The Red Hat Integration - Camel K 1.6 includes the OpenShift and Knative profiles. The Kubernetes profile has community-only support. It also includes Java, and YAML DSL support for integrations. Other languages such as XML, Groovy, JavaScript, and Kotlin have community-only support.

This chapter includes the following sections:

Camel K feature traits

Camel K core platform traits

6.1. Camel K trait and profile configuration

This section explains the important Camel K concepts of traits and profiles, which are used to configure advanced Camel K features at runtime.

Camel K traits

Camel K traits are advanced features and core capabilities that you can configure on the command line to customize Camel K integrations. For example, this includes feature traits that configure interactions with technologies such as 3scale API Management, Quarkus, Knative, and Prometheus. Camel K also provides internal platform traits that configure important core platform capabilities such as Camel support, containers, dependency resolution, and JVM support.

Camel K profiles

Camel K profiles define the target cloud platforms on which Camel K integrations run. Supported profiles are OpenShift and Knative profiles.

Note

When you run an integration on OpenShift, Camel K uses the Knative profile when OpenShift Serverless is installed on the cluster. Camel K uses the OpenShift profile when OpenShift Serverless is not installed.

You can also specify the profile at runtime using the kamel run --profile option.

Camel K provides useful defaults for all traits, taking into account the target profile on which the integration runs. However, advanced users can configure Camel K traits for custom behavior. Some traits only apply to specific profiles such as OpenShift or Knative. For more details, see the available profiles in each trait description.

Camel K trait configuration

Each Camel trait has a unique ID that you can use to configure the trait on the command line. For example, the following command disables creating an OpenShift Service for an integration:

kamel run --trait service.enabled=false my-integration.yaml

You can also use the -t option to specify traits.

Camel K trait properties

You can use the enabled property to enable or disable each trait. All traits have their own internal logic to determine if they need to be enabled when the user does not activate them explicitly.

Warning

Disabling a platform trait may compromise the platform functionality.

Some traits have an auto property, which you can use to enable or disable automatic configuration of the trait based on the environment. For example, this includes traits such as 3scale, Cron, and Knative. This automatic configuration can enable or disable the trait when the enabled property is not explicitly set, and can change the trait configuration.

Most traits have additional properties that you can configure on the command line. For more details, see the descriptions for each trait in the sections that follow.

6.2. Camel K feature traits

6.2.1. Health Trait

The health trait is responsible for configuring the health probes on the integration container.

It is disabled by default.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.1.1. Configuration

Trait properties are specified when running any integration by using the following CLI.

$ kamel run --trait health.[key]=[value] --trait health.[key2]=[value2] integration.java

The following configuration options are available.

PropertyTypeDescription

health.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

health.liveness-probe-enabled

bool

Configures the liveness probe for the integration container (default false).

health.liveness-scheme

string

Scheme to use when connecting to the liveness probe (default HTTP).

health.liveness-initial-delay

int32

Number of seconds after the container has started before the liveness probe is initiated.

health.liveness-timeout

int32

Number of seconds after which the liveness probe times out.

health.liveness-period

int32

How often to perform the liveness probe.

health.liveness-success-threshold

int32

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

health.liveness-failure-threshold

int32

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

health.readiness-probe-enabled

bool

Configures the readiness probe for the integration container (default true).

health.readiness-scheme

string

Scheme to use when connecting to the readiness probe (default HTTP).

health.readiness-initial-delay

int32

Number of seconds after the container has started before the readiness probe is initiated.

health.readiness-timeout

int32

Number of seconds after which the readiness probe times out.

health.readiness-period

int32

How often to perform the readiness probe.

health.readiness-success-threshold

int32

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

health.readiness-failure-threshold

int32

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

health.startup-probe-enabled

bool

Configures the startup probe for the integration container (default false).

health.startup-scheme

string

Scheme to use when connecting to the startup probe (default HTTP).

health.startup-initial-delay

int32

Number of seconds after the container has started before the startup probe is initiated.

health.startup-timeout

int32

Number of seconds after which the startup probe times out.

health.startup-period

int32

How often to perform the startup probe.

health.startup-success-threshold

int32

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

health.startup-failure-threshold

int32

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

6.2.2. Knative Trait

The Knative trait automatically discovers addresses of Knative resources and inject them into the running integration.

The full Knative configuration is injected in the CAMEL_KNATIVE_CONFIGURATION in JSON format. The Camel Knative component will then use the full configuration to configure the routes.

The trait is enabled by default when the Knative profile is active.

This trait is available in the following profiles: Knative.

6.2.2.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait knative.[key]=[value] --trait knative.[key2]=[value2] integration.java

The following configuration options are available:

PropertyTypeDescription

knative.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

knative.configuration

string

Can be used to inject a Knative complete configuration in JSON format.

knative.channel-sources

[]string

List of channels used as source of integration routes. Can contain simple channel names or full Camel URIs.

knative.channel-sinks

[]string

List of channels used as destination of integration routes. Can contain simple channel names or full Camel URIs.

knative.endpoint-sources

[]string

List of channels used as source of integration routes.

knative.endpoint-sinks

[]string

List of endpoints used as destination of integration routes. Can contain simple endpoint names or full Camel URIs.

knative.event-sources

[]string

List of event types that the integration will be subscribed to. Can contain simple event types or full Camel URIs (to use a specific broker different from "default").

knative.event-sinks

[]string

List of event types that the integration will produce. Can contain simple event types or full Camel URIs (to use a specific broker).

knative.filter-source-channels

bool

Enables filtering on events based on the header "ce-knativehistory". Since this header has been removed in newer versions of Knative, filtering is disabled by default.

knative.sink-binding

bool

Allows binding the integration to a sink via a Knative SinkBinding resource. This can be used when the integration targets a single sink. It’s enabled by default when the integration targets a single sink (except when the integration is owned by a Knative source).

knative.auto

bool

Enable automatic discovery of all trait properties.

6.2.3. Knative Service Trait

The Knative Service trait allows to configure options when running the integration as Knative service instead of a standard Kubernetes Deployment.

Running integrations as Knative Services adds auto-scaling (and scaling-to-zero) features, but those features are only meaningful when the routes use a HTTP endpoint consumer.

This trait is available in the following profiles: Knative.

6.2.3.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait knative-service.[key]=[value] --trait knative-service.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

knative-service.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

knative-service.annotations

map[string]string

The annotations are added to route. This can be used to set knative service specific annotations. For more details see, Route Specific Annotations.

CLI usage example: -t "knative-service.annotations.'haproxy.router.openshift.io/balance'=roundrobin"

knative-service.autoscaling-class

string

Configures the Knative autoscaling class property (e.g. to set hpa.autoscaling.knative.dev or kpa.autoscaling.knative.dev autoscaling).

Refer to the Knative documentation for more information.

knative-service.autoscaling-metric

string

Configures the Knative autoscaling metric property (e.g. to set concurrency based or cpu based autoscaling).

Refer to the Knative documentation for more information.

knative-service.autoscaling-target

int

Sets the allowed concurrency level or CPU percentage (depending on the autoscaling metric) for each Pod.

Refer to the Knative documentation for more information.

knative-service.min-scale

int

The minimum number of Pods that should be running at any time for the integration. It’s zero by default, meaning that the integration is scaled down to zero when not used for a configured amount of time.

Refer to the Knative documentation for more information.

knative-service.max-scale

int

An upper bound for the number of Pods that can be running in parallel for the integration. Knative has its own cap value that depends on the installation.

Refer to the Knative documentation for more information.

knative-service.auto

bool

Automatically deploy the integration as Knative service when all conditions hold:

  • Integration is using the Knative profile
  • All routes are either starting from a HTTP based consumer or a passive consumer (e.g. direct is a passive consumer)

6.2.4. Logging Trait

The Logging trait is used to configure Integration runtime logging options (such as color and format). The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.4.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait logging.[key]=[value] --trait logging.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

logging.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

logging.color

bool

Colorize the log output

logging.format

string

Logs message format

logging.level

string

Adjust the logging level (defaults to INFO)

logging.json

bool

Output the logs in JSON

logging.json-pretty-print

bool

Enable "pretty printing" of the JSON logs

6.2.5. Master Trait

The Master trait allows to configure the integration to automatically leverage Kubernetes resources for leader election and starting master routes only on certain instances.

It is activated automatically when using the master endpoint in a route. For example: from("master:lockname:telegram:bots")…​.

Note

This trait adds special permissions to the integration service account to read/write configmaps and read pods. It is recommended to use a different service account than "default" when running the integration.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.5.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait master.[key]=[value] --trait master.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

master.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

master.auto

bool

Enables automatic configuration of the trait.

master.include-delegate-dependencies

bool

When this flag is active, the operator analyzes the source code to add dependencies required by delegate endpoints. For example: when using master:lockname:timer, then camel:timer is automatically added to the set of dependencies. It is enabled by default.

master.resource-name

string

Name of the configmap/lease resource that will be used to store the lock. Defaults to "<integration-name>-lock".

master.resource-type

string

Type of Kubernetes resource to use for locking ("ConfigMap" or "Lease"). Defaults to "Lease".

master.label-key

string

Label that will be used to identify all pods contending the lock. Defaults to "camel.apache.org/integration".

master.label-value

string

Label value that will be used to identify all pods contending the lock. Defaults to the integration name.

6.2.6. Mount Trait

The Mount trait can be used to configure volumes mounted on the Integration Pods.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Note

The mount trait is a platform trait and cannot be disabled by the user.

6.2.6.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait mount.[key]=[value] --trait mount.[key2]=[value2] integration.java

The following configuration options are available:

PropertyTypeDescription

mount.enabled

bool

Deprecated: no longer in use.

mount.configs

[]string

A list of configuration pointing to configmap/secret. The configuration are expected to be UTF-8 resources as they are processed by runtime Camel Context and tried to be parsed as property files. They are also made available on the classpath in order to ease their usage directly from the Route.

mount.resources

[]string

A list of resources (text or binary content) pointing to configmap/secret. The resources are expected to be any resource type (text or binary content). The destination path can be either a default location or any path specified by the user.

mount.volumes

[]string

A list of Persistent Volume Claims to be mounted. Syntax:

mount.hot-reload

bool

Enable "hot reload" when a secret/configmap mounted is edited (default false)

Note
  1. The syntax for mount.configs property is, Syntax: [configmap | secret]:name[/key], where name represents the resource name and key optionally represents the resource key to be filtered.
  2. The syntax for mount.resources property is, Syntax: [configmap | secret]:name[/key] [@path], where name represents the resource name, key optionally represents the resource key to be filtered and path represents the destination path.

6.2.7. Telemetry Trait

Important

Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production.

These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview.

The Telemetry trait can be used to automatically publish tracing information to an OTLP compatible collector.

The trait is able to automatically discover the telemetry OTLP endpoint available in the namespace (supports Jaerger in version 1.35+).

The Telemetry trait is disabled by default.

Warning

The Telemetry trait cannot be enabled at the same time as the Tracing trait.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.7.1. Configuration

Trait properties can be specified when running any integration with the CLI.

$ kamel run --trait telemetry.[key]=[value] --trait telemetry.[key2]=[value2] integration.java

The following configuration options are available:

PropertyTypeDescription

telemetry.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

telemetry.auto

bool

Enables automatic configuration of the trait, including automatic discovery of the telemetry endpoint.

telemetry.service-name

string

The name of the service that publishes telemetry data (defaults to the integration name)

telemetry.endpoint

string

The target endpoint of the Telemetry service (automatically discovered by default)

telemetry.sampler

string

The sampler of the telemetry used for tracing (default "on")

telemetry.sampler-ratio

string

The sampler ratio of the telemetry used for tracing

telemetry.sampler-parent-based

bool

The sampler of the telemetry used for tracing is parent based (default "true")

6.2.7.2. Examples

  • To activate tracing to a deployed OTLP API Jaeger through discovery:

    $ kamel run -t telemetry.enable=true ...
  • To define a specific deployed OTLP gRPC reciever:

    $ kamel run -t telemetry.enable=true -t telemetry.endpoint=http://instance-collector:4317 ...
  • To define another sampler service name:

    $ kamel run -t telemetry.enable=true -t telemetry.service-name=tracer_myintegration ...
  • To use a ratio sampler with a sampling ratio of 1 to every 1,000 :

    $ kamel run -t telemetry.enable=true -t telemetry.sampler=ratio -t telemetry.sampler-ratio=0.001 ...

6.2.8. Pod Trait

The pod trait allows the customization of the Integration pods. It applies the PodSpecTemplate struct contained in the Integration .spec.podTemplate field, into the Integration deployment Pods template, using strategic merge patch.

This is used to customize the container where Camel routes execute, by using the integration container name.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Note 1: In the current implementation, template options override the configuration options defined by using CLI. For example:

$ kamel run Integration.java --pod-template template.yaml --env TEST_VARIABLE=will_be_overriden --env ANOTHER_VARIABLE=Im_There

The value from the template overwrites the TEST_VARIABLE environment variable, while ANOTHER_VARIABLE is unchanged.

Note 2: Changes to the integration container entrypoint are not applied due to current trait execution order.

6.2.8.1. Configuration

Trait properties are specified when running any integration by using the CLI.

$ kamel run --trait pod.[key]=[value] integration.java

The following configuration options are available.

PropertyTypeDescription

pod.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

6.2.8.2. Sidecar Containers

Example with the following Integration, that reads files from a directory:

Integration.groovy

from('file:///var/log')
 .convertBodyTo(String.class)
 .setBody().simple('${body}:  {{TEST_VARIABLE}} ')
 .log('${body}')

In addition, the following Pod template adds a sidecar container to the Integration Pod, generating some data into the directory, and mounts it into the integration container.

template.yaml

containers:
  - name: integration
    env:
      - name: TEST_VARIABLE
        value: "hello from the template"
    volumeMounts:
      - name: var-logs
        mountPath: /var/log
  - name: sidecar
    image: busybox
    command: [ "/bin/sh" , "-c", "while true; do echo $(date -u) 'Content from the sidecar container' > /var/log/file.txt; sleep 1;done" ]
    volumeMounts:
      - name: var-logs
        mountPath: /var/log
volumes:
  - name: var-logs
    emptyDir: { }

The Integration route logs the content of the file generated by the sidecar container. Example:

$ kamel run Integration.java --pod-template template.yaml
...
Condition "Ready" is "True" for Integration integration
[1] 2021-04-30 07:40:03,136 INFO  [route1] (Camel (camel-1) thread #0 - file:///var/log) Fri Apr 30 07:40:02 UTC 2021 Content from the sidecar container
[1] :  hello from the template
[1] 2021-04-30 07:40:04,140 INFO  [route1] (Camel (camel-1) thread #0 - file:///var/log) Fri Apr 30 07:40:03 UTC 2021 Content from the sidecar container
[1] :  hello from the template
[1] 2021-04-30 07:40:05,142 INFO  [route1] (Camel (camel-1) thread #0 - file:///var/log) Fri Apr 30 07:40:04 UTC 2021 Content from the sidecar container
[1] :  hello from the template

6.2.8.3. Init Containers

With this trait you are able to run initContainers. To run the initContainers, you must do the following.

  • Include at least one container in the template spec.
  • Provide the configuration for the default container, which is integration.

Following is a simple example.

template.yaml

containers:
  - name: integration
initContainers:
  - name: init
    image: busybox
    command: [ "/bin/sh" , "-c", "echo 'hello'!" ]

The integration container is overwritten by the container running the route, and the initContainer runs before the route as expected.

6.2.9. Prometheus Trait

The Prometheus trait configures a Prometheus-compatible endpoint. It also creates a PodMonitor resource, so that the endpoint can be scraped automatically, when using the Prometheus operator.

The metrics are exposed using MicroProfile Metrics.

Warning

The creation of the PodMonitor resource requires the Prometheus Operator custom resource definition to be installed. You can set pod-monitor to false for the Prometheus trait to work without the Prometheus Operator.

The Prometheus trait is disabled by default.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.9.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait prometheus.[key]=[value] --trait prometheus.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

prometheus.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

prometheus.pod-monitor

bool

Whether a PodMonitor resource is created (default true).

prometheus.pod-monitor-labels

[]string

The PodMonitor resource labels, applicable when pod-monitor is true.

6.2.10. Pdb Trait

The PDB trait allows to configure the PodDisruptionBudget resource for the Integration pods.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.10.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait pdb.[key]=[value] --trait pdb.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

pdb.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

pdb.min-available

string

The number of pods for the Integration that must still be available after an eviction. It can be either an absolute number or a percentage. Only one of min-available and max-unavailable can be specified.

pdb.max-unavailable

string

The number of pods for the Integration that can be unavailable after an eviction. It can be either an absolute number or a percentage (default 1 if min-available is also not set). Only one of max-unavailable and min-available can be specified.

6.2.11. Pull Secret Trait

The Pull Secret trait sets a pull secret on the pod, to allow Kubernetes to retrieve the container image from an external registry.

The pull secret can be specified manually or, in case you’ve configured authentication for an external container registry on the IntegrationPlatform, the same secret is used to pull images.

It’s enabled by default whenever you configure authentication for an external container registry, so it assumes that external registries are private.

If your registry does not need authentication for pulling images, you can disable this trait.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.2.11.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait pull-secret.[key]=[value] --trait pull-secret.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

pull-secret.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

pull-secret.secret-name

string

The pull secret name to set on the Pod. If left empty this is automatically taken from the IntegrationPlatform registry configuration.

pull-secret.image-puller-delegation

bool

When using a global operator with a shared platform, this enables delegation of the system:image-puller cluster role on the operator namespace to the integration service account.

pull-secret.auto

bool

Automatically configures the platform registry secret on the pod if it is of type kubernetes.io/dockerconfigjson.

6.2.12. Route Trait

The Route trait can be used to configure the creation of OpenShift routes for the integration.

The certificate and key contents may be sourced either from the local filesystem or in a Openshift secret object. The user may use the parameters ending in -secret (example: tls-certificate-secret) to reference a certificate stored in a secret. Parameters ending in -secret have higher priorities and in case the same route parameter is set, for example: tls-key-secret and tls-key, then tls-key-secret is used. The recommended approach to set the key and certificates is to use secrets to store their contents and use the following parameters to reference them: tls-certificate-secret, tls-key-secret, tls-ca-certificate-secret, tls-destination-ca-certificate-secret See the examples section at the end of this page to see the setup options.

This trait is available in the following profiles: OpenShift.

6.2.12.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait route.[key]=[value] --trait route.[key2]=[value2] integration.java

The following configuration options are available:

PropertyTypeDescription

route.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

route.annotations

map[string]string

The annotations are added to route. This can be used to set route specific annotations. For annotations options see Route Specific Annotations. CLI usage example: -t "route.annotations.'haproxy.router.openshift.io/balance'=roundrobin

route.host

string

To configure the host exposed by the route.

route.tls-termination

string

The TLS termination type, like edge, passthrough or reencrypt.

Refer to the OpenShift route documentation for additional information.

route.tls-certificate

string

The TLS certificate contents.

Refer to the OpenShift route documentation for additional information.

route.tls-certificate-secret

string

The secret name and key reference to the TLS certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".

Refer to the OpenShift route documentation for additional information.

route.tls-key

string

The TLS certificate key contents.

Refer to the OpenShift route documentation for additional information.

route.tls-key-secret

string

The secret name and key reference to the TLS certificate key. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".

Refer to the OpenShift route documentation for additional information.

route.tls-ca-certificate

string

The TLS CA certificate contents.

Refer to the OpenShift route documentation for additional information.

route.tls-ca-certificate-secret

string

The secret name and key reference to the TLS CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".

Refer to the OpenShift route documentation for additional information.

route.tls-destination-ca-certificate

string

The destination CA certificate provides the contents of the ca certificate of the final destination. When using reencrypt termination this file should be provided in order to have routers use it for health checks on the secure connection. If this field is not specified, the router may provide its own destination CA and perform hostname validation using the short service name (service.namespace.svc), which allows infrastructure generated certificates to automatically verify.

Refer to the OpenShift route documentation for additional information.

route.tls-destination-ca-certificate-secret

string

The secret name and key reference to the destination CA certificate. The format is "secret-name[/key-name]", the value represents the secret name, if there is only one key in the secret it will be read, otherwise you can set a key name separated with a "/".

Refer to the OpenShift route documentation for additional information.

route.tls-insecure-edge-termination-policy

string

To configure how to deal with insecure traffic, e.g. Allow, Disable or Redirect traffic.

Refer to the OpenShift route documentation for additional information.

6.2.12.2. Examples

These examples uses secrets to store the certificates and keys to be referenced in the integrations. Read Openshift route documentation for detailed information about routes. The PlatformHttpServer.java is the integration example.

As a requirement to run these examples, you should have a secret with a key and certificate.

openssl genrsa -out tls.key
openssl req -new -key tls.key -out csr.csr -subj "/CN=my-server.com"
openssl x509 -req -in csr.csr -signkey tls.key -out tls.crt
oc create secret tls my-combined-certs --key=tls.key  --cert=tls.crt
6.2.12.2.2. Making an HTTP request to the route

For all examples, you can use the following curl command to make an HTTP request. It makes use of inline scripts to retrieve the openshift namespace and cluster base domain, if you are using a shell which doesn’t support these inline scripts, you should replace the inline scripts with the values of your actual namespace and base domain.

curl -k https://platform-http-server-`oc config view --minify -o 'jsonpath={..namespace}'`.`oc get dnses/cluster -ojsonpath='{.spec.baseDomain}'`/hello?name=Camel-K
  • To add an edge route using secrets, use the parameters ending in -secret to set the secret name which contains the certificate. This route example trait references a secret named my-combined-certs which contains two keys named tls.key and tls.crt.

    kamel run --dev PlatformHttpServer.java -t route.tls-termination=edge -t route.tls-certificate-secret=my-combined-certs/tls.crt -t route.tls-key-secret=my-combined-certs/tls.key
  • To add a passthrough route using secrets, the TLS is setup in the integration pod, the keys and certificates should be visible in the running integration pod, to achieve this we are using the --resource kamel parameter to mount the secret in the integration pod, then we use some camel quarkus parameters to reference these certificate files in the running pod, they start with -p quarkus.http.ssl.certificate. This route example trait references a secret named my-combined-certs which contains two keys named tls.key and tls.crt.

    kamel run --dev PlatformHttpServer.java --resource secret:my-combined-certs@/etc/ssl/my-combined-certs -p quarkus.http.ssl.certificate.file=/etc/ssl/my-combined-certs/tls.crt -p quarkus.http.ssl.certificate.key-file=/etc/ssl/my-combined-certs/tls.key -t route.tls-termination=passthrough -t container.port=8443
  • To add a reencrypt route using secrets, the TLS is setup in the integration pod, the keys and certificates should be visible in the running integration pod, to achieve this we are using the --resource kamel parameter to mount the secret in the integration pod, then we use some camel quarkus parameters to reference these certificate files in the running pod, they start with -p quarkus.http.ssl.certificate. This route example trait references a secret named my-combined-certs which contains two keys named tls.key and tls.crt.

    kamel run --dev PlatformHttpServer.java --resource secret:my-combined-certs@/etc/ssl/my-combined-certs  -p quarkus.http.ssl.certificate.file=/etc/ssl/my-combined-certs/tls.crt -p quarkus.http.ssl.certificate.key-file=/etc/ssl/my-combined-certs/tls.key -t route.tls-termination=reencrypt -t route.tls-destination-ca-certificate-secret=my-combined-certs/tls.crt -t route.tls-certificate-secret=my-combined-certs/tls.crt -t route.tls-key-secret=my-combined-certs/tls.key -t container.port=8443
  • To add a reencrypt route using a specific certificate from a secret for the route and Openshift service serving certificates for the integration endpoint. This way the Openshift service serving certificates is set up only in the integration pod. The keys and certificates should be visible in the running integration pod, to achieve this we are using the --resource kamel parameter to mount the secret in the integration pod, then we use some camel quarkus parameters to reference these certificate files in the running pod, they start with -p quarkus.http.ssl.certificate. This route example trait references a secret named my-combined-certs which contains two keys named tls.key and tls.crt.

    kamel run --dev PlatformHttpServer.java --resource secret:cert-from-openshift@/etc/ssl/cert-from-openshift  -p quarkus.http.ssl.certificate.file=/etc/ssl/cert-from-openshift/tls.crt -p quarkus.http.ssl.certificate.key-file=/etc/ssl/cert-from-openshift/tls.key -t route.tls-termination=reencrypt -t route.tls-certificate-secret=my-combined-certs/tls.crt -t route.tls-key-secret=my-combined-certs/tls.key -t container.port=8443

    Then you should annotate the integration service to inject the Openshift service serving certificates

    oc annotate service platform-http-server service.beta.openshift.io/serving-cert-secret-name=cert-from-openshift
  • To add an edge route using a certificate and a private key provided from your local filesystem. This example uses inline scripts to read the certificate and private key file contents, then remove all new line characters, (this is required to set the certificate as parameter’s values), so the values are in a single line.

    kamel run PlatformHttpServer.java --dev -t route.tls-termination=edge -t route.tls-certificate="$(cat tls.crt|awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}')" -t route.tls-key="$(cat tls.key|awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}')"

6.2.13. Service Trait

The Service trait 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.

This trait is available in the following profiles: Kubernetes, OpenShift.

6.2.13.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait service.[key]=[value] --trait service.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

service.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

service.auto

bool

To automatically detect from the code if a Service needs to be created.

service.node-port

bool

Enable Service to be exposed as NodePort (default false).

6.3. Camel K platform traits

6.3.1. Builder Trait

The builder trait is internally used to determine the best strategy to build and configure IntegrationKits.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The builder trait is a platform trait: disabling it may compromise the platform functionality.

6.3.1.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait builder.[key]=[value] --trait builder.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

builder.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

builder.verbose

bool

Enable verbose logging on build components that support it (e.g., OpenShift build pod). Kaniko and Buildah are not supported.

builder.properties

[]string

A list of properties to be provided to the build task

6.3.2. Container Trait

The Container trait can be used to configure properties of the container where the integration will run.

It also provides configuration for Services associated to the container.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The container trait is a platform trait: disabling it may compromise the platform functionality.

6.3.2.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait container.[key]=[value] --trait container.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

container.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

container.auto

bool

 

container.request-cpu

string

The minimum amount of CPU required.

container.request-memory

string

The minimum amount of memory required.

container.limit-cpu

string

The maximum amount of CPU required.

container.limit-memory

string

The maximum amount of memory required.

container.expose

bool

Can be used to enable/disable exposure via kubernetes Service.

container.port

int

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

container.port-name

string

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

container.service-port

int

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

container.service-port-name

string

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

container.name

string

The main container name. It’s named integration by default.

container.image

string

The main container image

container.probes-enabled

bool

ProbesEnabled enable/disable probes on the container (default false)

6.3.3. Camel Trait

The Camel trait can be used to configure versions of Apache Camel K runtime and related libraries, it cannot be disabled.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The camel trait is a platform trait: disabling it may compromise the platform functionality.

6.3.3.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait camel.[key]=[value] --trait camel.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

camel.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

6.3.4. Dependencies Trait

The Dependencies trait is internally used to automatically add runtime dependencies based on the integration that the user wants to run.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The dependencies trait is a platform trait: disabling it may compromise the platform functionality.

6.3.4.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait dependencies.[key]=[value] Integration.java

The following configuration options are available:

PropertyTypeDescription

dependencies.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

6.3.5. Deployer Trait

The deployer trait can be used to explicitly select the kind of high level resource that will deploy the integration.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The deployer trait is a platform trait: disabling it may compromise the platform functionality.

6.3.5.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait deployer.[key]=[value] --trait deployer.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

deployer.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

deployer.kind

string

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

6.3.6. Deployment Trait

The Deployment trait is responsible for generating the Kubernetes deployment that will make sure the integration will run in the cluster.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The deployment trait is a platform trait: disabling it may compromise the platform functionality.

6.3.6.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait deployment.[key]=[value] Integration.java

The following configuration options are available:

PropertyTypeDescription

deployment.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

6.3.7. Environment Trait

The environment trait is used internally to inject standard environment variables in the integration container, such as NAMESPACE, POD_NAME and others.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The environment trait is a platform trait: disabling it may compromise the platform functionality.

6.3.7.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait environment.[key]=[value] --trait environment.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

environment.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

environment.container-meta

bool

Enables injection of NAMESPACE and POD_NAME environment variables (default true)

6.3.8. Error Handler Trait

The error-handler is a platform trait used to inject Error Handler source into the integration runtime.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The error-handler trait is a platform trait: disabling it may compromise the platform functionality.

6.3.8.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait error-handler.[key]=[value] --trait error-handler.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

error-handler.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

error-handler.ref

string

The error handler ref name provided or found in application properties

6.3.9. Jvm Trait

The JVM trait is used to configure the JVM that runs the integration.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The jvm trait is a platform trait: disabling it may compromise the platform functionality.

6.3.9.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait jvm.[key]=[value] --trait jvm.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

jvm.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

jvm.debug

bool

Activates remote debugging, so that a debugger can be attached to the JVM, e.g., using port-forwarding

jvm.debug-suspend

bool

Suspends the target JVM immediately before the main class is loaded

jvm.print-command

bool

Prints the command used the start the JVM in the container logs (default true)

jvm.debug-address

string

Transport address at which to listen for the newly launched JVM (default *:5005)

jvm.options

[]string

A list of JVM options

jvm.classpath

string

Additional JVM classpath (use Linux classpath separator)

6.3.9.2. Examples

  • Include an additional classpath to the Integration:

    $ kamel run -t jvm.classpath=/path/to/my-dependency.jar:/path/to/another-dependency.jar ...

6.3.10. Kamelets Trait

The kamelets trait is a platform trait used to inject Kamelets into the integration runtime.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The kamelets trait is a platform trait: disabling it may compromise the platform functionality.

6.3.10.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait kamelets.[key]=[value] --trait kamelets.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

kamelets.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

kamelets.auto

bool

Automatically inject all referenced Kamelets and their default configuration (enabled by default)

kamelets.list

string

Comma separated list of Kamelet names to load into the current integration

6.3.11. NodeAffinity Trait

The NodeAffinity trait enables you to constrain the nodes that the integration pods are eligible to schedule on, through the following paths:

  • 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.

This trait is disabled by default.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

6.3.11.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait affinity.[key]=[value] --trait affinity.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

affinity.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

affinity.pod-affinity

bool

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

affinity.pod-anti-affinity

bool

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

affinity.node-affinity-labels

[]string

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

affinity.pod-affinity-labels

[]string

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-labels

[]string

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.

6.3.11.2. 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.

6.3.12. Openapi Trait

The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The openapi trait is a platform trait: disabling it may compromise the platform functionality.

6.3.12.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait openapi.[key]=[value] Integration.java

The following configuration options are available:

PropertyTypeDescription

openapi.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

6.3.13. Owner Trait

The Owner trait ensures that all created resources belong to the integration being created and transfers annotations and labels on the integration onto these owned resources.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The owner trait is a platform trait: disabling it may compromise the platform functionality.

6.3.13.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait owner.[key]=[value] --trait owner.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

owner.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

owner.target-annotations

[]string

The set of annotations to be transferred

owner.target-labels

[]string

The set of labels to be transferred

6.3.14. Platform Trait

The platform trait is a base trait that is used to assign an integration platform to an integration.

In case the platform is missing, the trait is allowed to create a default platform. This feature is especially useful in contexts where there’s no need to provide a custom configuration for the platform (e.g. on OpenShift the default settings work, since there’s an embedded container image registry).

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The platform trait is a platform trait: disabling it may compromise the platform functionality.

6.3.14.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait platform.[key]=[value] --trait platform.[key2]=[value2] Integration.java

The following configuration options are available:

PropertyTypeDescription

platform.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

platform.create-default

bool

To create a default (empty) platform when the platform is missing.

platform.global

bool

Indicates if the platform should be created globally in the case of global operator (default true).

platform.auto

bool

To automatically detect from the environment if a default platform can be created (it will be created on OpenShift only).

6.3.15. Quarkus Trait

The Quarkus trait activates the Quarkus runtime.

It’s enabled by default.

Note

Compiling to a native executable, i.e. when using package-type=native, is only supported for kamelets, as well as YAML integrations. It also requires at least 4GiB of memory, so the Pod running the native build, that is either the operator Pod, or the build Pod (depending on the build strategy configured for the platform), must have enough memory available.

This trait is available in the following profiles: Kubernetes, Knative, OpenShift.

Warning

The quarkus trait is a platform trait: disabling it may compromise the platform functionality.

6.3.15.1. Configuration

Trait properties can be specified when running any integration with the CLI:

$ kamel run --trait quarkus.[key]=[value] --trait quarkus.[key2]=[value2] integration.java

The following configuration options are available:

PropertyTypeDescription

quarkus.enabled

bool

Can be used to enable or disable a trait. All traits share this common property.

quarkus.package-type

[]github.com/apache/camel-k/pkg/trait.quarkusPackageType

The Quarkus package types, either fast-jar or native (default fast-jar). In case both fast-jar and native are specified, two IntegrationKit resources are created, with the native kit having precedence over the fast-jar one once ready. The order influences the resolution of the current kit for the integration. The kit corresponding to the first package type will be assigned to the integration in case no existing kit that matches the integration exists.

6.3.15.2. Supported Camel Components

Camel K only supports the Camel components that are available as Camel Quarkus Extensions out-of-the-box.

6.3.15.3. Examples

While the compilation to native executables produces integrations that start faster and consume less memory at runtime, the build process is resources intensive, and takes a longer time than the packaging to traditional Java applications.

In order to combine the best of both worlds, it’s possible to configure the Quarkus trait to run both traditional and native builds in parallel when running an integration, e.g.:

$ kamel run -t quarkus.package-type=fast-jar -t quarkus.package-type=native ...

The integration pod will run as soon as the fast-jar build completes, and a rollout deployment to the native image will be triggered, as soon as the native build completes, with no service interruption.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top