User manual

Camel CLI - Kubernetes Plugin Advanced Options

The Kubernetes Plugin page covers what most applications need. This page lists the less common settings: the trait options the plugin inherited from Camel K, running as a CronJob, Knative, and the Jolokia port.

Trait options

The Kubernetes manifest is generated by traits, a concept from Camel K. A trait option is set with --trait <trait>.<option>=<value> on camel kubernetes run and camel kubernetes export, and some of them have their own shortcut option (such as --env, --config or --volume).

A trait option can be set in several places, in this order of precedence:

  1. --trait command options

  2. Annotations with prefix trait.camel.apache.org/* (--annotation)

  3. Properties in application-<profile>.properties with prefix camel.jbang.trait.*

  4. Properties in application.properties with prefix camel.jbang.trait.*

Setting them in application.properties keeps them with the project, so every run and export uses them:

camel.jbang.trait.container.request-memory=256Mi
camel.jbang.trait.service.type=LoadBalancer

Container trait

Customize the container specification (image, ports, resources):

Property Type Description

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. It defaults to http only when the expose parameter is true.

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 application container name.

container.image

string

The application container image to use for the Deployment.

container.image-pull-policy

PullPolicy

The pull policy: Always|Never|IfNotPresent

container.image-pull-secrets

string[]

The pull secrets for private registries

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.

Example:

camel kubernetes export Sample.java --trait container.name=my-container --trait container.port=8088 --trait container.request-cpu=0.005 --trait container.request-memory=100Mi

CronJob trait (run as a scheduled job)

Generate a CronJob instead of a Deployment (requires enabled=true and schedule):

camel kubernetes export Sample.java --trait=cronjob.enabled=true --trait=cronjob.schedule="* * * * 2"
Property Type Description

cronjob.enabled

boolean

To generate the CronJob manifest instead of Deployment. (default=false)

cronjob.schedule

string

To set the schedule to run the workload following the crontab format.

cronjob.timezone

string

To set the timezone to run the workload.

cronjob.startingDeadlineSeconds

integer

To set the StartingDeadlineSeconds field of the CronJob.

cronjob.activeDeadlineSeconds

integer

To set the ActiveDeadlineSeconds field of the CronJob.

cronjob.backoffLimit

integer

To set the BackoffLimit field of the CronJob.

cronjob.durationMaxIdleSeconds

integer

To set the camel.main.duration-max-idle-seconds property for how long time in seconds Camel can be idle before automatic terminating the JVM. (default 1)

Service trait

A Service resource is auto-generated when routes expose HTTP endpoints (e.g., platform-http). Customize it:

Property Type Description

service.type

string

The type of service to be used, either 'ClusterIP', 'NodePort' or 'LoadBalancer'.

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

Ingress trait

Add an Ingress resource to expose the application externally (requires a Service resource):

Property Type Description

ingress.enabled

bool

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

ingress.annotations

map[string]string

The annotations added to the ingress. This can be used to set controller-specific annotations, e.g., when using the NGINX Ingress controller.

ingress.host

string

To configure the host exposed by the ingress.

ingress.path

string

To configure the path exposed by the ingress (default /).

ingress.pathType

string

To configure the path type exposed by the ingress. One of Exact, Prefix, ImplementationSpecific (default to Prefix).

ingress.auto

bool

To automatically add an Ingress Resource whenever the route uses an HTTP endpoint consumer (default true).

ingress.tls-hosts

[]string

To configure specific hosts exposed through SNI TLS extension by the ingess.

ingress.tls-secret-name

string

To indicate the secret containing the TLS private key and certificate to use for TLS.

Example:

camel kubernetes export Sample.java --trait ingress.enabled=true --trait ingress.host=example.com --trait ingress.path=/sample

Route trait (OpenShift)

Add an OpenShift Route resource to expose the application externally:

Property Type Description

route.enabled

bool

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

route.annotations

map[string]string

The annotations added to the route. This can be used to set openshift route specific annotations options.

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 or file (file:absolute.path). Refer to the OpenShift route documentation for additional information.

route.tls-key

string

The TLS certificate key contents or file (file:absolute.path). Refer to the OpenShift route documentation for additional information.

route.tls-ca-certificate

string

The TLS CA certificate contents or file (file:absolute.path). Refer to the OpenShift route documentation for additional information.

route.tls-destination-ca-certificate

string

The destination CA contents or file (file:absolute.path). The destination CA certificate provides the contents of the CA certificate of the final destination. When using reencrypt termination, this file should be provided 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-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.

Example:

camel kubernetes export Sample.java --cluster-type=openshift --trait route.enabled=true --trait route.host=example.com --trait route.tls-termination=edge

Jolokia trait

Enable JMX access via Jolokia (requires Jolokia configured in the application):

Property Type Description

jolokia.enabled

bool

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

jolokia.container-port

int

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

jolokia.container-port-name

string

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

jolokia.expose

bool

Can be used to enable/disable exposure of jolokia via kubernetes Service. (default false).

jolokia.service-port

int

To configure a different jolokia port exposed by the service (default 8778). It is applied only when the expose parameter is true.

jolokia.service-port-name

string

To configure a different port name for the port exposed by the service (default jolokia). It is applied only when the expose parameter is true.

Example:

camel kubernetes export Sample.java --trait jolokia.enabled=true --trait jolokia.expose=true

Mount trait

Configure volume mounts from ConfigMaps, Secrets, and PVCs. Shortcuts: --volume, --config, --resource.

Property Type Description

mount.configs

[]string

A list of configuration pointing to configmap/secret. The configurations 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 to ease their usage directly from the Route. Syntax: [configmap|secret]:name[/key], where name represents the resource name and key optionally represents the resource key to be filtered

mount.resources

[]string

A list of resources (text or binary content) pointing to a 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. 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

mount.volumes

[]string

A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]

Example:

camel kubernetes export Sample.java --config secret:my-credentials --resource configmap:my-data --volume my-pvc:/container/path

Mount paths follow Camel conventions: configs go to /etc/camel/conf.d/, resources to /etc/camel/resources.d/, and the application is auto-configured to read these paths.

OpenAPI trait

Mount OpenAPI specs from ConfigMaps:

camel kubernetes export Sample.java --open-api configmap:my-spec

Environment trait

--env KEY=VALUE is the shortcut of the environment trait, --trait environment.vars=KEY=VALUE.

Knative

Knative runs the application as a serverless service (Knative serving) and connects it to event brokers and channels (Knative eventing). The plugin generates the Knative resources for the Knative component used in the routes.

Knative service trait

Use Knative serving for serverless workloads with auto-scaling and scale-to-zero.

Disabled by default — enable with --trait knative-service.enabled=true.
Property Type Description

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 added to route. This can be used to set knative service-specific annotations CLI usage example: -t "knative-service.annotations.'haproxy.router.openshift.io/balance'=true"

knative-service.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.rollout-duration

string

Enables to gradually shift traffic to the latest Revision and sets the rollout duration. It’s disabled by default and must be expressed as a Golang time.Duration string representation, rounded to a second precision.

knative-service.visibility

string

Setting cluster-local, Knative service becomes a private service. Specifically, this option applies the networking.knative.dev/visibility label to Knative service.

Refer to the Knative documentation for more information.

knative-service.timeout-seconds

int

The maximum duration in seconds that the request instance is allowed to respond to a request. This field propagates to the integration Pod’s terminationGracePeriodSeconds.

Refer to the Knative documentation for more information.

Knative component trait

Configure the Camel Knative component to interact with Knative eventing and Knative serving. The export auto-configures both the component and the Kubernetes manifest.

Disabled by default — enable with --trait knative.enabled=true.
Property Type Description

knative.enabled

bool

Can be used to enable or disable a trait. (default: true)

knative.configuration

string

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

knative.channel-sinks

[]string

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

Refer to the Knative documentation for more information.

knative.channel-sources

[]string

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

knative.endpoint-sinks

[]string

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

knative.endpoint-sources

[]string

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

knative.event-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.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.filters

[]string

Sets filter attributes on the event stream (such as event type, source, subject and so on). A list of key-value pairs that represent filter attributes and its values. The syntax is KEY=VALUE, e.g., source="my.source". Filter attributes get set on the Knative trigger that is being created as part of this integration.

knative.filter-event-type

bool

Enables the default filtering for the Knative trigger using the event type If this is true, the created Knative trigger uses the event type as a filter on the event stream when no other filter criteria is given. (default: true)

Knative trigger

When a route consumes from knative:event, the plugin automatically generates a Knative Trigger in the manifest:

- route:
    from:
      uri: knative:event/camel.evt.type
      parameters:
        name: my-broker
      steps:
        - to:
            uri: log:info

Export with camel kubernetes export knative-route.yaml — the trigger, service, and knative.json configuration are all generated automatically.

Knative channel subscription

Similarly, routes consuming from knative:channel/my-channel automatically generate a Knative Subscription in the manifest. The knative.json configuration is auto-generated.

Knative sink binding

Routes that produce to knative:event, knative:channel, or knative:endpoint automatically get a SinkBinding resource in the manifest. Knative injects the target URL via the K_SINK environment variable at deployment time, so the route doesn’t need to know the actual URL.