Kubernetes
JVM since1.0.0 Native since1.0.0
Perform operations against Kubernetes API
What’s inside
-
Kubernetes ConfigMap component, URI syntax:
kubernetes-config-maps:masterUrl
-
Kubernetes Custom Resources component, URI syntax:
kubernetes-custom-resources:masterUrl
-
Kubernetes Deployments component, URI syntax:
kubernetes-deployments:masterUrl
-
Kubernetes Event component, URI syntax:
kubernetes-events:masterUrl
-
Kubernetes HPA component, URI syntax:
kubernetes-hpa:masterUrl
-
Kubernetes Job component, URI syntax:
kubernetes-job:masterUrl
-
Kubernetes Namespaces component, URI syntax:
kubernetes-namespaces:masterUrl
-
Kubernetes Nodes component, URI syntax:
kubernetes-nodes:masterUrl
-
Kubernetes Persistent Volume component, URI syntax:
kubernetes-persistent-volumes:masterUrl
-
Kubernetes Persistent Volume Claim component, URI syntax:
kubernetes-persistent-volumes-claims:masterUrl
-
Kubernetes Pods component, URI syntax:
kubernetes-pods:masterUrl
-
Kubernetes Replication Controller component, URI syntax:
kubernetes-replication-controllers:masterUrl
-
Kubernetes Resources Quota component, URI syntax:
kubernetes-resources-quota:masterUrl
-
Kubernetes Secrets component, URI syntax:
kubernetes-secrets:masterUrl
-
Kubernetes Service Account component, URI syntax:
kubernetes-service-accounts:masterUrl
-
Kubernetes Services component, URI syntax:
kubernetes-services:masterUrl
-
Openshift Build Config component, URI syntax:
openshift-build-configs:masterUrl
-
Openshift Builds component, URI syntax:
openshift-builds:masterUrl
-
Openshift Deployment Configs component, URI syntax:
openshift-deploymentconfigs:masterUrl
Please refer to the above links for usage and configuration details.
Maven coordinates
Or add the coordinates to your existing project:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kubernetes</artifactId>
</dependency>
Check the User guide for more information about writing Camel Quarkus applications.
Additional Camel Quarkus configuration
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
:
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 Quarkus Kubernetes Client guide.
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 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.
Configuration property | Type | Default |
---|---|---|
Whether a Kubernetes Cluster Service should be automatically configured according to 'quarkus.camel.cluster.kubernetes.*' configurations. |
|
|
The cluster service ID (defaults to null). |
| |
The URL of the Kubernetes master (read from Kubernetes client properties by default). |
| |
The connection timeout in milliseconds to use when making requests to the Kubernetes API server. |
| |
The name of the Kubernetes namespace containing the pods and the configmap (autodetected by default). |
| |
The name of the current pod (autodetected from container host name by default). |
| |
The jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant (defaults to 1.2). |
| |
The default duration of the lease for the current leader (defaults to 15000). |
| |
The deadline after which the leader must stop its services because it may have lost the leadership (defaults to 10000). |
| |
The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor (defaults to 2000). |
| |
Service lookup order/priority (defaults to 2147482647). |
| |
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. |
| |
The lease resource type used in Kubernetes, either 'config-map' or 'lease' (defaults to 'lease'). |
| |
Whether the camel master namespace leaders should be distributed evenly across all the camel contexts in the cluster. |
|
|
The labels key/value used to identify the pods composing the cluster, defaults to empty map. |
|
Configuration property fixed at build time. All other configuration properties are overridable at runtime.