[[kubernetes-component]]
= Kubernetes Component (deprecated)
:page-source: components/camel-kubernetes/src/main/docs/kubernetes-component.adoc

*Available as of Camel version 2.17*

[IMPORTANT]
====================================================================================
The composite kubernetes component has been deprecated. Use individual
component splitted as following.

* Kubernetes Components
  ** xref:openshift-build-configs-component.adoc[Kubernetes Build Config]
  ** Kubernetes Build
  ** xref:kubernetes-config-maps-component.adoc[Kubernetes ConfigMap]
  ** xref:kubernetes-namespaces-component.adoc[Kubernetes Namespace]
  ** xref:kubernetes-nodes-component.adoc[Kubernetes Node]
  ** xref:kubernetes-persistent-volumes-component.adoc[Kubernetes Persistent Volume]
  ** xref:kubernetes-persistent-volumes-claims-component.adoc[Kubernetes Persistent Volume Claim]
  ** xref:kubernetes-pods-component.adoc[Kubernetes Pod]
  ** xref:kubernetes-replication-controllers-component.adoc[Kubernetes Replication Controller]
  ** xref:kubernetes-resources-quota-component.adoc[Kubernetes Resource Quota]
  ** xref:kubernetes-secrets-component.adoc[Kubernetes Secrets]
  ** xref:kubernetes-service-accounts-component.adoc[Kubernetes Service Account]
  ** xref:kubernetes-services-component.adoc[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:

[source,xml]
------------------------------------------------------------
<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>
------------------------------------------------------------

== URI format

[source,java]
------------------------------
kubernetes:masterUrl[?options]
------------------------------

You can append query options to the URI in the following
format, `?option=value&option=value&...`

== Options


// component options: START
The Kubernetes component has no options.
// component options: END








// endpoint options: START
The Kubernetes endpoint is configured using URI syntax:

----
kubernetes:masterUrl
----

with the following path and query parameters:

=== Path Parameters (1 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *masterUrl* | *Required* Kubernetes Master url |  | String
|===


=== Query Parameters (29 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| 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
|===
// endpoint options: END
// spring-boot-auto-configure options: START
== Spring Boot Auto-Configuration

When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

[source,xml]
----
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-kubernetes-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>
----


The component supports 16 options, which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| 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 master (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
|===
// spring-boot-auto-configure options: END








=== Headers

[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|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
|=======================================================================


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

=== Usage

==== Producer examples

Here we show some examples of producer using camel-kubernetes.

==== Create a pod

[source,java]
-------------------------------------------------------------
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.

==== Delete a pod

[source,java]
-------------------------------------------------------------
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.