// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-kubernetes"]
= Kubernetes
:page-aliases: extensions/kubernetes.adoc
:linkattrs:
:cq-artifact-id: camel-quarkus-kubernetes
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Perform operations against Kubernetes API
:cq-deprecated: false
:cq-jvm-since: 1.0.0
:cq-native-since: 1.0.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0##
endif::[]

Perform operations against Kubernetes API

[id="extensions-kubernetes-whats-inside"]
== What's inside

* xref:{cq-camel-components}::kubernetes-config-maps-component.adoc[Kubernetes ConfigMap component], URI syntax: `kubernetes-config-maps:masterUrl`
* xref:{cq-camel-components}::kubernetes-cronjob-component.adoc[Kubernetes Cronjob component], URI syntax: `kubernetes-cronjob:masterUrl`
* xref:{cq-camel-components}::kubernetes-custom-resources-component.adoc[Kubernetes Custom Resources component], URI syntax: `kubernetes-custom-resources:masterUrl`
* xref:{cq-camel-components}::kubernetes-deployments-component.adoc[Kubernetes Deployments component], URI syntax: `kubernetes-deployments:masterUrl`
* xref:{cq-camel-components}::kubernetes-events-component.adoc[Kubernetes Event component], URI syntax: `kubernetes-events:masterUrl`
* xref:{cq-camel-components}::kubernetes-hpa-component.adoc[Kubernetes HPA component], URI syntax: `kubernetes-hpa:masterUrl`
* xref:{cq-camel-components}::kubernetes-job-component.adoc[Kubernetes Job component], URI syntax: `kubernetes-job:masterUrl`
* xref:{cq-camel-components}::kubernetes-namespaces-component.adoc[Kubernetes Namespaces component], URI syntax: `kubernetes-namespaces:masterUrl`
* xref:{cq-camel-components}::kubernetes-nodes-component.adoc[Kubernetes Nodes component], URI syntax: `kubernetes-nodes:masterUrl`
* xref:{cq-camel-components}::kubernetes-persistent-volumes-component.adoc[Kubernetes Persistent Volume component], URI syntax: `kubernetes-persistent-volumes:masterUrl`
* xref:{cq-camel-components}::kubernetes-persistent-volumes-claims-component.adoc[Kubernetes Persistent Volume Claim component], URI syntax: `kubernetes-persistent-volumes-claims:masterUrl`
* xref:{cq-camel-components}::kubernetes-pods-component.adoc[Kubernetes Pods component], URI syntax: `kubernetes-pods:masterUrl`
* xref:{cq-camel-components}::kubernetes-replication-controllers-component.adoc[Kubernetes Replication Controller component], URI syntax: `kubernetes-replication-controllers:masterUrl`
* xref:{cq-camel-components}::kubernetes-resources-quota-component.adoc[Kubernetes Resources Quota component], URI syntax: `kubernetes-resources-quota:masterUrl`
* xref:{cq-camel-components}::kubernetes-secrets-component.adoc[Kubernetes Secrets component], URI syntax: `kubernetes-secrets:masterUrl`
* xref:{cq-camel-components}::kubernetes-service-accounts-component.adoc[Kubernetes Service Account component], URI syntax: `kubernetes-service-accounts:masterUrl`
* xref:{cq-camel-components}::kubernetes-services-component.adoc[Kubernetes Services component], URI syntax: `kubernetes-services:masterUrl`
* xref:{cq-camel-components}::openshift-build-configs-component.adoc[Openshift Build Config component], URI syntax: `openshift-build-configs:masterUrl`
* xref:{cq-camel-components}::openshift-builds-component.adoc[Openshift Builds component], URI syntax: `openshift-builds:masterUrl`
* xref:{cq-camel-components}::openshift-deploymentconfigs-component.adoc[Openshift Deployment Configs component], URI syntax: `openshift-deploymentconfigs:masterUrl`

Please refer to the above links for usage and configuration details.

[id="extensions-kubernetes-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-kubernetes[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-kubernetes</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-kubernetes-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

ifeval::[{doc-show-extra-content} == true]
include::extra-content.adoc[]
endif::[]

[id="extensions-kubernetes-configuration-automatic-registration-of-a-kubernetes-client-instance"]
=== Automatic registration of a Kubernetes Client instance

The extension automatically registers a Kubernetes Client bean named `kubernetesClient`. You can reference the bean in your routes like this:

    from("direct:pods")
        .to("kubernetes-pods:///?kubernetesClient=#kubernetesClient&operation=listPods")

By default the client is configured from the local kubeconfig file. You can customize the client configuration via properties within `application.properties`:

[source,properties]
----
quarkus.kubernetes-client.master-url=https://my.k8s.host
quarkus.kubernetes-client.namespace=my-namespace
----

The full set of configuration options are documented in the https://quarkus.io/guides/kubernetes-client#quarkus-kubernetes-client_configuration[Quarkus Kubernetes Client guide].

[id="extensions-kubernetes-configuration-having-only-a-single-consumer-in-a-cluster-consuming-from-a-given-endpoint"]
=== Having only a single consumer in a cluster consuming from a given endpoint

When the same route is deployed on multiple pods, it could be interesting to use this extension in conjunction with the xref:reference/extensions/master.adoc[Master one].
In such a setup, a single consumer will be active at a time across the whole camel master namespace.

For instance, having the route below deployed on multiple pods:

```
from("master:ns:timer:test?period=100").log("Timer invoked on a single pod at a time");
```

It's possible to enable the kubernetes cluster service with a property like below:

```
quarkus.camel.cluster.kubernetes.enabled = true
```

As a result, a single consumer will be active across the `ns` camel master namespace.
It means that, at a given time, only a single timer will generate exchanges across the whole cluster.
In other words, messages will be logged every 100ms on a single pod at a time.

The kubernetes cluster service could further be tuned by tweaking `quarkus.camel.cluster.kubernetes.*` properties.


[width="100%",cols="80,5,15",options="header"]
|===
| Configuration property | Type | Default


|icon:lock[title=Fixed at build time] [[quarkus.camel.cluster.kubernetes.enabled]]`link:#quarkus.camel.cluster.kubernetes.enabled[quarkus.camel.cluster.kubernetes.enabled]`

Whether a Kubernetes Cluster Service should be automatically configured according to 'quarkus.camel.cluster.kubernetes.++*++' configurations.
| `boolean`
| `false`

|icon:lock[title=Fixed at build time] [[quarkus.camel.cluster.kubernetes.rebalancing]]`link:#quarkus.camel.cluster.kubernetes.rebalancing[quarkus.camel.cluster.kubernetes.rebalancing]`

Whether the camel master namespace leaders should be distributed evenly across all the camel contexts in the cluster.
| `boolean`
| `true`

| [[quarkus.camel.cluster.kubernetes.id]]`link:#quarkus.camel.cluster.kubernetes.id[quarkus.camel.cluster.kubernetes.id]`

The cluster service ID (defaults to null).
| `string`
| 

| [[quarkus.camel.cluster.kubernetes.master-url]]`link:#quarkus.camel.cluster.kubernetes.master-url[quarkus.camel.cluster.kubernetes.master-url]`

The URL of the Kubernetes master (read from Kubernetes client properties by default).
| `string`
| 

| [[quarkus.camel.cluster.kubernetes.connection-timeout-millis]]`link:#quarkus.camel.cluster.kubernetes.connection-timeout-millis[quarkus.camel.cluster.kubernetes.connection-timeout-millis]`

The connection timeout in milliseconds to use when making requests to the Kubernetes API server.
| `java.lang.Integer`
| 

| [[quarkus.camel.cluster.kubernetes.namespace]]`link:#quarkus.camel.cluster.kubernetes.namespace[quarkus.camel.cluster.kubernetes.namespace]`

The name of the Kubernetes namespace containing the pods and the configmap (autodetected by default).
| `string`
| 

| [[quarkus.camel.cluster.kubernetes.pod-name]]`link:#quarkus.camel.cluster.kubernetes.pod-name[quarkus.camel.cluster.kubernetes.pod-name]`

The name of the current pod (autodetected from container host name by default).
| `string`
| 

| [[quarkus.camel.cluster.kubernetes.jitter-factor]]`link:#quarkus.camel.cluster.kubernetes.jitter-factor[quarkus.camel.cluster.kubernetes.jitter-factor]`

The jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant (defaults to 1.2).
| `java.lang.Double`
| 

| [[quarkus.camel.cluster.kubernetes.lease-duration-millis]]`link:#quarkus.camel.cluster.kubernetes.lease-duration-millis[quarkus.camel.cluster.kubernetes.lease-duration-millis]`

The default duration of the lease for the current leader (defaults to 15000).
| `java.lang.Long`
| 

| [[quarkus.camel.cluster.kubernetes.renew-deadline-millis]]`link:#quarkus.camel.cluster.kubernetes.renew-deadline-millis[quarkus.camel.cluster.kubernetes.renew-deadline-millis]`

The deadline after which the leader must stop its services because it may have lost the leadership (defaults to 10000).
| `java.lang.Long`
| 

| [[quarkus.camel.cluster.kubernetes.retry-period-millis]]`link:#quarkus.camel.cluster.kubernetes.retry-period-millis[quarkus.camel.cluster.kubernetes.retry-period-millis]`

The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor (defaults to 2000).
| `java.lang.Long`
| 

| [[quarkus.camel.cluster.kubernetes.order]]`link:#quarkus.camel.cluster.kubernetes.order[quarkus.camel.cluster.kubernetes.order]`

Service lookup order/priority (defaults to 2147482647).
| `java.lang.Integer`
| 

| [[quarkus.camel.cluster.kubernetes.resource-name]]`link:#quarkus.camel.cluster.kubernetes.resource-name[quarkus.camel.cluster.kubernetes.resource-name]`

The name of the lease resource used to do optimistic locking (defaults to 'leaders'). The resource name is used as prefix when the underlying Kubernetes resource can manage a single lock.
| `string`
| 

| [[quarkus.camel.cluster.kubernetes.lease-resource-type]]`link:#quarkus.camel.cluster.kubernetes.lease-resource-type[quarkus.camel.cluster.kubernetes.lease-resource-type]`

The lease resource type used in Kubernetes, either 'config-map' or 'lease' (defaults to 'lease').
| `org.apache.camel.component.kubernetes.cluster.LeaseResourceType`
| 

| [[quarkus.camel.cluster.kubernetes.labels]]`link:#quarkus.camel.cluster.kubernetes.labels[quarkus.camel.cluster.kubernetes.labels]`

The labels key/value used to identify the pods composing the cluster, defaults to empty map.
| ``Map<String,String>``
| 
|===

[.configuration-legend]
{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.

