Camel Components

OpenShift Deployment Configs

Since Camel 3.18

Both producer and consumer are supported

The Openshift Deployment Configs component is one of Kubernetes Components which provides a producer to execute Openshift Deployment Configs operations and a consumer to consume events related to Deployment Configs objects.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The OpenShift Deployment Configs component supports the following options which are listed below.

Name Description Default Type

kubernetesClient (common)

Autowired An existing Kubernetes client for the endpoints of this component that do not set their own kubernetesClient option. The endpoints then do not use the options that configure the client (masterUrl, credentials, certificates, trustCerts, apiVersion, connectionTimeout).

KubernetesClient

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

Endpoint Options

The OpenShift Deployment Configs endpoint is configured using URI syntax:

openshift-deploymentconfigs:masterUrl

With the following path and query parameters:

Path Parameters

Name Description Default Type

masterUrl (common)

Required The URL of the Kubernetes API server, such as https://kubernetes.default.svc. Use local or client to create the Kubernetes client from the auto-detected configuration (kubeconfig file, in-cluster service account, system properties and environment variables) without applying the options that configure the client (credentials, certificates, trustCerts, apiVersion, connectionTimeout). With a URL, the client also starts from the auto-detected configuration, and these options override it. Not used when the kubernetesClient option is set.

String

Query Parameters

Name Description Default Type

apiVersion (common)

The default API version of the Kubernetes client (the client default is v1). The client uses it only for a resource type that does not give its own version, and the resource types of these components all give theirs.

String

dnsDomain (common)

Not used. It was the DNS domain for the ServiceCall EIP, which was removed in Camel 4.19.

String

kubernetesClient (common)

An existing Kubernetes client to use. The options that configure the client (masterUrl, credentials, certificates, trustCerts, apiVersion, connectionTimeout) are then not used, and Camel does not close the client when the endpoint stops.

KubernetesClient

namespace (common)

The namespace of the resources. For the producer, the CamelKubernetesNamespaceName header takes precedence. When neither is set, the list operations and the consumer cover all namespaces, and the operations on a single resource fail; openshift-deploymentconfigs then uses the namespace of the Kubernetes client, and kubernetes-custom-resources fails. Not used by kubernetes-namespaces, kubernetes-nodes and kubernetes-persistent-volumes, whose resources are cluster-scoped. When Camel creates the client from a URL, it is also the default namespace of the client.

String

portName (common)

Not used. It was the port name for the ServiceCall EIP, which was removed in Camel 4.19.

String

portProtocol (common)

Not used. It was the port protocol for the ServiceCall EIP, which was removed in Camel 4.19.

tcp

String

crdGroup (consumer)

The API group of the custom resource, such as sources.knative.dev. Used only by kubernetes-custom-resources: the consumer requires it, and the producer uses the CamelKubernetesCRDGroup header when it is not set.

String

crdName (consumer)

The name of the custom resource definition (CRD), such as githubsources.sources.knative.dev. Used only by kubernetes-custom-resources: the consumer requires it, and the producer uses the CamelKubernetesCRDName header when it is not set.

String

crdPlural (consumer)

The plural name of the custom resource, as used in its API path, such as githubsources. Used only by kubernetes-custom-resources: the consumer requires it, and the producer uses the CamelKubernetesCRDPlural header when it is not set.

String

crdScope (consumer)

The scope of the custom resource: Namespaced or Cluster (the client takes any value other than Namespaced as cluster-scoped). Used only by kubernetes-custom-resources: the consumer requires it, and the producer uses the CamelKubernetesCRDScope header when it is not set.

String

crdVersion (consumer)

The version of the custom resource API, such as v1alpha1. Used only by kubernetes-custom-resources: the consumer requires it, and the producer uses the CamelKubernetesCRDVersion header when it is not set.

String

labelKey (consumer)

The label key that the consumer filters the watched resources on. Used only together with labelValue, and it takes precedence over resourceName. Not used by kubernetes-custom-resources.

String

labelValue (consumer)

The label value that the consumer filters the watched resources on. Used only together with labelKey. Not used by kubernetes-custom-resources.

String

poolSize (consumer)

The number of threads of the consumer that create the watch, and watch again when the Kubernetes client closed it with an error. The client delivers the events one at a time on its own threads, so one thread is enough.

1

int

resourceName (consumer)

The name of the single resource that the consumer watches. Not used when labelKey and labelValue are set, nor when namespace is not set, except by kubernetes-namespaces and kubernetes-nodes, whose resources are cluster-scoped. Not used by kubernetes-custom-resources.

String

bridgeErrorHandler (consumer (advanced))

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

exceptionHandler (consumer (advanced))

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

ExceptionHandler

exchangePattern (consumer (advanced))

Sets the exchange pattern when the consumer creates an exchange.

Enum values:

  • InOnly

  • InOut

ExchangePattern

operation (producer)

The producer operation to perform, such as listPods or createConfigMap; the page of each component lists its operations. When it is not set, the CamelKubernetesOperation header gives the operation; the option takes precedence over the header.

String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

connectionTimeout (advanced)

The timeout in milliseconds to establish a connection to the API server. When it is not set, the Kubernetes client default of 10000 applies; 0 or less leaves the timeout to the HTTP client implementation.

Integer

caCertData (security)

The certificate of the certificate authority (CA) to trust for the API server, as Base64-encoded PEM data. Takes precedence over caCertFile.

String

caCertFile (security)

The path of a PEM file with the certificate of the certificate authority (CA) to trust for the API server. caCertData takes precedence over it.

String

clientCertData (security)

The client certificate for TLS client authentication, as Base64-encoded PEM data. Takes precedence over clientCertFile, and is used only together with clientKeyData or clientKeyFile.

String

clientCertFile (security)

The path of a PEM file with the client certificate for TLS client authentication. Used only together with clientKeyData or clientKeyFile; clientCertData takes precedence over it.

String

clientKeyAlgo (security)

The algorithm of the client private key: RSA (the default of the Kubernetes client) or EC.

String

clientKeyData (security)

The private key for TLS client authentication, as Base64-encoded unencrypted PEM data. Takes precedence over clientKeyFile.

String

clientKeyFile (security)

The path of a file with the private key for TLS client authentication, as unencrypted PEM. clientKeyData takes precedence over it.

String

clientKeyPassphrase (security)

The password with which the Kubernetes client protects the client private key in the key store that it builds in memory (the client default is changeit). It does not decrypt the key, which must be unencrypted.

String

oauthToken (security)

The bearer token to authenticate to the API server, such as a service account token or an OAuth access token. When it is set, username and password are not used.

String

password (security)

The password for HTTP basic authentication to the API server. Used only together with username, and not when oauthToken is set.

String

trustCerts (security)

Whether to trust any certificate of the API server without checking it. This is insecure: set caCertData or caCertFile instead. Setting it to false does not override true from the auto-detected configuration.

Boolean

username (security)

The username for HTTP basic authentication to the API server. Used only together with password, and not when oauthToken is set.

String

Message Headers

The OpenShift Deployment Configs component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelKubernetesOperation (producer)

Constant: KUBERNETES_OPERATION

The operation of the producer, such as listPods or createConfigMap. Used only when the operation option of the endpoint is not set; one of the two is required.

String

CamelKubernetesNamespaceName (producer)

Constant: KUBERNETES_NAMESPACE_NAME

The namespace of the resource, which takes precedence over the namespace option of the endpoint. For kubernetes-namespaces, it is instead the name of the namespace to get, create, update or delete, where it is required. When no namespace is set, the list operations cover all namespaces (openshift-deploymentconfigs: the namespace of the Kubernetes client), getConfigMap, getDeployment and getDeploymentConfig use the namespace of the Kubernetes client, and the other operations fail; kubernetes-custom-resources requires a namespace for every operation.

String

CamelKubernetesDeploymentsLabels (producer)

Constant: KUBERNETES_DEPLOYMENTS_LABELS

The labels, as a map of label keys to values: listDeploymentsByLabels and listDeploymentConfigsByLabels (where they are required) list only the Deployments or DeploymentConfigs that have all of them, and the create and update operations set them as the labels of the Deployment or DeploymentConfig.

Map

CamelKubernetesDeploymentsAnnotations (producer)

Constant: KUBERNETES_DEPLOYMENTS_ANNOTATIONS

The annotations, as a map of keys to values, that createDeployment and updateDeployment set on the Deployment. openshift-deploymentconfigs does not use them.

Map

CamelKubernetesDeploymentName (producer)

Constant: KUBERNETES_DEPLOYMENT_NAME

The name of the Deployment or DeploymentConfig for the get, create, update, delete and scale operations, where it is required.

String

CamelKubernetesDeploymentReplicas (producer)

Constant: KUBERNETES_DEPLOYMENT_REPLICAS

The desired number of replicas (pods) for scaleDeployment and scaleDeploymentConfig, where it is required.

Integer

CamelKubernetesDeploymentConfigSpec (producer)

Constant: KUBERNETES_DEPLOYMENT_CONFIG_SPEC

The DeploymentConfigSpec of the DeploymentConfig to create or update; required for createDeploymentConfig and updateDeploymentConfig.

DeploymentConfigSpec

CamelKubernetesEventAction (consumer)

Constant: KUBERNETES_EVENT_ACTION

The action of the watch event that the consumer received: ADDED, MODIFIED or DELETED. For kubernetes-events, the createEvent and updateEvent operations of the producer read a header of the same name as the action of the Event.

Enum values:

  • ADDED

  • MODIFIED

  • DELETED

  • ERROR

  • BOOKMARK

Action

CamelKubernetesEventTimestamp (consumer)

Constant: KUBERNETES_EVENT_TIMESTAMP

The time when the consumer received the watch event, in milliseconds since the Unix epoch (not the time of the change in Kubernetes).

long

Message Body

The message body at each side of the OpenShift Deployment Configs component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Consumer

pojo (io.fabric8.openshift.api.model.DeploymentConfig)

The DeploymentConfig that changed, one message per watch event, with the action (ADDED, MODIFIED, DELETED) in the CamelKubernetesEventAction header.

Producer input

any

Not used: the operation (the operation option, or else the CamelKubernetesOperation header) takes its input from headers: the namespace in CamelKubernetesNamespaceName (else the namespace option), the name in CamelKubernetesDeploymentName, the labels in CamelKubernetesDeploymentsLabels, the DeploymentConfigSpec in CamelKubernetesDeploymentConfigSpec and the replicas in CamelKubernetesDeploymentReplicas. Without a namespace the list and get operations use the namespace of the client.

Producer output

list, pojo, null or value

A List of DeploymentConfig for listDeploymentConfigs and listDeploymentConfigsByLabels; the DeploymentConfig for getDeploymentConfig (null when not found), createDeploymentConfig and updateDeploymentConfig; a Boolean for deleteDeploymentConfig, false when not found; for scaleDeploymentConfig the replicas in the spec of the scaled deployment config, as an Integer.

  • With operation=listDeploymentConfigs: list (java.util.List<io.fabric8.openshift.api.model.DeploymentConfig>)

  • With operation=listDeploymentConfigsByLabels: list (java.util.List<io.fabric8.openshift.api.model.DeploymentConfig>)

  • With operation=getDeploymentConfig: pojo or null (io.fabric8.openshift.api.model.DeploymentConfig)

  • With operation=createDeploymentConfig: pojo (io.fabric8.openshift.api.model.DeploymentConfig)

  • With operation=updateDeploymentConfig: pojo (io.fabric8.openshift.api.model.DeploymentConfig)

  • With operation=deleteDeploymentConfig: value (java.lang.Boolean)

  • With operation=scaleDeploymentConfig: value (java.lang.Integer)

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Usage

Supported producer operation

  • listDeploymentConfigs

  • listDeploymentConfigsByLabels

  • getDeploymentConfig

  • createDeploymentConfig

  • updateDeploymentConfig

  • deleteDeploymentConfig

  • scaleDeploymentConfig

The operations use the namespace of the CamelKubernetesNamespaceName header, or else of the namespace option. Without a namespace, listDeploymentConfigs, listDeploymentConfigsByLabels and getDeploymentConfig use the namespace of the Kubernetes client; the other operations require one. listDeploymentConfigsByLabels requires the CamelKubernetesDeploymentsLabels header. scaleDeploymentConfig returns the replicas in the spec of the scaled deployment config.

Examples

Openshift Deployment Configs Producer Examples

  • listDeploymentConfigs: this operation lists the deployments on an Openshift cluster

  • Java

  • XML

  • YAML

from("direct:list")
    .to("openshift-deploymentconfigs:///?kubernetesClient=#kubernetesClient&operation=listDeploymentConfigs")
    .to("mock:result");
<route>
  <from uri="direct:list"/>
  <to uri="openshift-deploymentconfigs:///?kubernetesClient=#kubernetesClient&amp;operation=listDeploymentConfigs"/>
  <to uri="mock:result"/>
</route>
- route:
    from:
      uri: direct:list
      steps:
        - to:
            uri: openshift-deploymentconfigs:///
            parameters:
              kubernetesClient: "#kubernetesClient"
              operation: listDeploymentConfigs
        - to:
            uri: mock:result

This operation returns a list of deployment configs from your cluster

  • listDeploymentConfigsByLabels: this operation lists the deployment configs by labels on an Openshift cluster

Java-only: sets a Map header for label selection
from("direct:listByLabels")
    .process(exchange -> {
        exchange.getIn().setHeader("CamelKubernetesDeploymentsLabels",
            Map.of("key1", "value1", "key2", "value2"));
    })
    .to("openshift-deploymentconfigs:///?kubernetesClient=#kubernetesClient&operation=listDeploymentConfigsByLabels")
    .to("mock:result");

This operation returns a list of deployment configs from your cluster using a label selector (with key1 and key2, with value value1 and value2)

Openshift Deployment Configs Consumer Example

  • Java

  • XML

  • YAML

from("openshift-deploymentconfigs://{{kubernetes-host}}?oauthToken={{kubernetes-token}}")
    .to("log:result");
<route>
  <from uri="openshift-deploymentconfigs://{{kubernetes-host}}?oauthToken={{kubernetes-token}}"/>
  <to uri="log:result"/>
</route>
- route:
    from:
      uri: openshift-deploymentconfigs://{{kubernetes-host}}
      parameters:
        oauthToken: "{{kubernetes-token}}"
      steps:
        - to:
            uri: log:result

This consumer returns a message per event received for all DeploymentConfigs from all namespaces in the cluster.

You can narrow the scope of the consumer using the following query parameter combinations:

  • labelKey + labelValue - Watch DeploymentConfigs with the specified label in any namespace.

  • namespace - Watch all DeploymentConfigs in the specified namespace.

  • namespace + resourceName - Watch the DeploymentConfig with the specified name in the given namespace.

  • namespace + labelKey + labelValue - Watch DeploymentConfigs with the specified label in the given namespace.