Chapter 47. Kubernetes


Perform operations against Kubernetes API

47.1. Maven coordinates

Create a new project with this extension on code.quarkus.redhat.com

Or add the coordinates to your existing project:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-kubernetes</artifactId>
</dependency>
Copy to Clipboard Toggle word wrap

47.2. Additional Camel Quarkus configuration

Important

In this release of Camel Extensions for Quarkus, the camel-quarkus-kubernetes extension is only supported when used with the camel-quarkus-master extension as a cluster service. Additionally, in order for the camel-quarkus-kubernetes extension to be supported, you must explicitly add a dependency on the quarkus-openshift-client extension in your application.

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")
Copy to Clipboard Toggle word wrap

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

quarkus.kubernetes-client.master-url=https://my.k8s.host
quarkus.kubernetes-client.namespace=my-namespace
Copy to Clipboard Toggle word wrap

The full set of configuration options are documented in the Quarkus Kubernetes Client guide.

When the same route is deployed on multiple pods, it could be interesting to use this extension in conjunction with the 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");
Copy to Clipboard Toggle word wrap

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

quarkus.camel.cluster.kubernetes.enabled = true
Copy to Clipboard Toggle word wrap

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.

Expand
Configuration propertyTypeDefault

lock quarkus.camel.cluster.kubernetes.enabled

Whether a Kubernetes Cluster Service should be automatically configured according to 'quarkus.camel.cluster.kubernetes.*' configurations.

boolean

false

lock quarkus.camel.cluster.kubernetes-id

The cluster service ID (defaults to null).

string

 

lock quarkus.camel.cluster.kubernetes.master-url

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

string

 

lock 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

 

lock quarkus.camel.cluster.kubernetes.namespace

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

string

 

lock quarkus.camel.cluster.kubernetes.pod-name

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

string

 

lock 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

 

lock quarkus.camel.cluster.kubernetes.lease-duration-millis

The default duration of the lease for the current leader (defaults to 15000).

java.lang.Long

 

lock 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

 

lock 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

 

lock quarkus.camel.cluster.kubernetes-order

Service lookup order/priority (defaults to 2147482647).

java.lang.Integer

 

lock 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

 

lock 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

 

lock 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

lock quarkus.camel.cluster.kubernetes-labels

The labels key/value used to identify the pods composing the cluster, defaults to empty map.

Map<String,String>

 

lock Configuration property fixed at build time. All other configuration properties are overridable at runtime.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat