Chapter 196. Kubernetes Component (deprecated) Available as of Camel version 2.17 Important The composite kubernetes component has been deprecated. Use individual component splitted as following. Kubernetes Components Kubernetes Build Config Kubernetes Build Kubernetes ConfigMap Kubernetes Namespace Kubernetes Node Kubernetes Persistent Volume Kubernetes Persistent Volume Claim Kubernetes Pod Kubernetes Replication Controller Kubernetes Resource Quota Kubernetes Secrets Kubernetes Service Account Kubernetes Service The Kubernetes component is a component for integrating your application with Kubernetes standalone or on top of Openshift. Maven users will need to add the following dependency to their pom.xml for this component: <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-kubernetes</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> 196.1. URI format kubernetes:masterUrl[?options] You can append query options to the URI in the following format, ?option=value&option=value&... 196.2. Options The Kubernetes component has no options. The Kubernetes endpoint is configured using URI syntax: with the following path and query parameters: 196.2.1. Path Parameters (1 parameters): Name Description Default Type masterUrl Required Kubernetes API server URL String 196.2.2. Query Parameters (29 parameters): Name Description Default Type apiVersion (common) The Kubernetes API Version to use String category (common) Required Kubernetes Producer and Consumer category String dnsDomain (common) The dns domain, used for ServiceCall EIP String kubernetesClient (common) Default KubernetesClient to use if provided KubernetesClient portName (common) The port name, used for ServiceCall EIP String portProtocol (common) The port protocol, used for ServiceCall EIP tcp String bridgeErrorHandler (consumer) Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. 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 labelKey (consumer) The Consumer Label key when watching at some resources String labelValue (consumer) The Consumer Label value when watching at some resources String namespace (consumer) The namespace String poolSize (consumer) The Consumer pool size 1 int resourceName (consumer) The Consumer Resource Name we would like to watch String exceptionHandler (consumer) 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) Sets the exchange pattern when the consumer creates an exchange. ExchangePattern operation (producer) Producer operation to do on Kubernetes String connectionTimeout (advanced) Connection timeout in milliseconds to use when making requests to the Kubernetes API server. Integer synchronous (advanced) Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). false boolean caCertData (security) The CA Cert Data String caCertFile (security) The CA Cert File String clientCertData (security) The Client Cert Data String clientCertFile (security) The Client Cert File String clientKeyAlgo (security) The Key Algorithm used by the client String clientKeyData (security) The Client Key data String clientKeyFile (security) The Client Key file String clientKeyPassphrase (security) The Client Key Passphrase String oauthToken (security) The Auth Token String password (security) Password to connect to Kubernetes String trustCerts (security) Define if the certs we used are trusted anyway or not Boolean username (security) Username to connect to Kubernetes String 196.3. Spring Boot Auto-Configuration The component supports 16 options, which are listed below. Name Description Default Type camel.component.kubernetes.cluster.service.attributes Custom service attributes. Map camel.component.kubernetes.cluster.service.cluster-labels Set the labels used to identify the pods composing the cluster. Map camel.component.kubernetes.cluster.service.config-map-name Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders'). String camel.component.kubernetes.cluster.service.connection-timeout-millis Connection timeout in milliseconds to use when making requests to the Kubernetes API server. Integer camel.component.kubernetes.cluster.service.enabled Sets if the Kubernetes cluster service should be enabled or not, default is false. false Boolean camel.component.kubernetes.cluster.service.id Cluster Service ID String camel.component.kubernetes.cluster.service.jitter-factor A jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant. Double camel.component.kubernetes.cluster.service.kubernetes-namespace Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default) String camel.component.kubernetes.cluster.service.lease-duration-millis The default duration of the lease for the current leader. Long camel.component.kubernetes.cluster.service.master-url Set the URL of the Kubernetes API server URL (read from Kubernetes client properties by default). String camel.component.kubernetes.cluster.service.order Service lookup order/priority. Integer camel.component.kubernetes.cluster.service.pod-name Set the name of the current pod (autodetected from container host name by default). String camel.component.kubernetes.cluster.service.renew-deadline-millis The deadline after which the leader must stop its services because it may have lost the leadership. Long camel.component.kubernetes.cluster.service.retry-period-millis The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor. Long camel.component.kubernetes.enabled Whether to enable auto configuration of the kubernetes component. This is enabled by default. Boolean camel.component.kubernetes.resolve-property-placeholders Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. true Boolean 196.4. Headers Name Type Description CamelKubernetesOperation String The Producer operation CamelKubernetesNamespaceName String The Namespace name CamelKubernetesNamespaceLabels Map The Namespace Labels CamelKubernetesServiceLabels Map The Service labels CamelKubernetesServiceName String The Service name CamelKubernetesServiceSpec io.fabric8.kubernetes.api.model.ServiceSpec The Spec for a Service CamelKubernetesReplicationControllersLabels Map Replication controller labels CamelKubernetesReplicationControllerName String Replication controller name CamelKubernetesReplicationControllerSpec io.fabric8.kubernetes.api.model.ReplicationControllerSpec The Spec for a Replication Controller CamelKubernetesReplicationControllerReplicas Integer The number of replicas for a Replication Controller during the Scale operation CamelKubernetesPodsLabels Map Pod labels CamelKubernetesPodName String Pod name CamelKubernetesPodSpec io.fabric8.kubernetes.api.model.PodSpec The Spec for a Pod CamelKubernetesPersistentVolumesLabels Map Persistent Volume labels CamelKubernetesPersistentVolumesName String Persistent Volume name CamelKubernetesPersistentVolumesClaimsLabels Map Persistent Volume Claim labels CamelKubernetesPersistentVolumesClaimsName String Persistent Volume Claim name CamelKubernetesPersistentVolumesClaimsSpec io.fabric8.kubernetes.api.model.PersistentVolumeClaimSpec The Spec for a Persistent Volume claim CamelKubernetesSecretsLabels Map Secret labels CamelKubernetesSecretsName String Secret name CamelKubernetesSecret io.fabric8.kubernetes.api.model.Secret A Secret Object CamelKubernetesResourcesQuotaLabels Map Resource Quota labels CamelKubernetesResourcesQuotaName String Resource Quota name CamelKubernetesResourceQuotaSpec io.fabric8.kubernetes.api.model.ResourceQuotaSpec The Spec for a Resource Quota CamelKubernetesServiceAccountsLabels Map Service Account labels CamelKubernetesServiceAccountName String Service Account name CamelKubernetesServiceAccount io.fabric8.kubernetes.api.model.ServiceAccount A Service Account object CamelKubernetesNodesLabels Map Node labels CamelKubernetesNodeName String Node name CamelKubernetesBuildsLabels Map Openshift Build labels CamelKubernetesBuildName String Openshift Build name CamelKubernetesBuildConfigsLabels Map Openshift Build Config labels CamelKubernetesBuildConfigName String Openshift Build Config name CamelKubernetesEventAction io.fabric8.kubernetes.client.Watcher.Action Action watched by the consumer CamelKubernetesEventTimestamp String Timestamp of the action watched by the consumer CamelKubernetesConfigMapName String ConfigMap name CamelKubernetesConfigMapsLabels Map ConfigMap labels CamelKubernetesConfigData Map ConfigMap Data 196.5. Categories Actually the camel-kubernetes component supports the following Kubernetes resources Namespaces Pods Replication Controllers Services Persistent Volumes Persistent Volume Claims Secrets Resource Quota Service Accounts Nodes Configmaps In Openshift also Builds BuildConfigs 196.6. Usage 196.6.1. Producer examples Here we show some examples of producer using camel-kubernetes. 196.6.2. Create a pod from("direct:createPod") .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=createPod", host, authToken); By using the KubernetesConstants.KUBERNETES_POD_SPEC header you can specify your PodSpec and pass it to this operation. 196.6.3. Delete a pod from("direct:createPod") .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=deletePod", host, authToken); By using the KubernetesConstants.KUBERNETES_POD_NAME header you can specify your Pod name and pass it to this operation.

Commands:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-kubernetes</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
kubernetes:masterUrl[?options]
kubernetes:masterUrl
from("direct:createPod") .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=createPod", host, authToken);
from("direct:createPod") .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=deletePod", host, authToken);