You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2025/02/17 09:53:37 UTC
(camel) branch camel-4.10.x updated: Backport camel-kubernetes fixes to 4.10.x (#17176)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.10.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.10.x by this push:
new a0ee781ec43 Backport camel-kubernetes fixes to 4.10.x (#17176)
a0ee781ec43 is described below
commit a0ee781ec4348f2b976cb04de3d5fc56cee064de
Author: Andrej Vaňo <av...@redhat.com>
AuthorDate: Mon Feb 17 10:53:31 2025 +0100
Backport camel-kubernetes fixes to 4.10.x (#17176)
* CAMEL-21737: Fix camel-kubernetes consumer label handling and miscellaneous improvements
* fix(camel-kubernetes): Incorrect error message for empty jobspec
* fix(camel-kubernetes): Incorrect header for doListResourceQuotasByLabels
* fix(camel-kubernetes): Incorrect header for doGetServiceAccount
* feat(camel-kubernetes): Support listing configmaps in given namespace
* feat(camel-kubernetes): Propagate namespace to consumer
* docs(camel-kubernetes): Fix incorrect endpoint in namespaces docs
* fix(CAMEL-21733): Incorrect client handling to propagate parameters to consumers
* fix(camel-kubernetes): Use the namespace header in deployments operations (#17140)
---
.../docs/kubernetes-config-maps-component.adoc | 15 +-
.../docs/kubernetes-deployments-component.adoc | 17 +-
.../src/main/docs/kubernetes-events-component.adoc | 19 +-
.../src/main/docs/kubernetes-hpa-component.adoc | 14 +-
.../main/docs/kubernetes-namespaces-component.adoc | 19 +-
.../src/main/docs/kubernetes-nodes-component.adoc | 15 +-
.../src/main/docs/kubernetes-pods-component.adoc | 16 +-
...bernetes-replication-controllers-component.adoc | 17 +-
.../main/docs/kubernetes-services-component.adoc | 16 +-
.../openshift-deploymentconfigs-component.adoc | 15 +-
.../config_maps/KubernetesConfigMapsConsumer.java | 53 +++--
.../config_maps/KubernetesConfigMapsProducer.java | 22 +-
.../deployments/KubernetesDeploymentsConsumer.java | 47 +++-
.../deployments/KubernetesDeploymentsProducer.java | 29 ++-
.../events/KubernetesEventsConsumer.java | 49 ++--
.../kubernetes/hpa/KubernetesHPAConsumer.java | 52 +++--
.../kubernetes/job/KubernetesJobProducer.java | 4 +-
.../namespaces/KubernetesNamespacesConsumer.java | 15 +-
.../kubernetes/nodes/KubernetesNodesConsumer.java | 19 +-
.../kubernetes/pods/KubernetesPodsConsumer.java | 47 ++--
.../KubernetesReplicationControllersConsumer.java | 49 ++--
.../KubernetesResourcesQuotaProducer.java | 18 +-
.../KubernetesServiceAccountsProducer.java | 2 +-
.../services/KubernetesServicesConsumer.java | 48 ++--
.../OpenshiftDeploymentConfigsConsumer.java | 47 +++-
.../KubernetesConfigMapsConsumerIT.java | 183 ---------------
.../integration/KubernetesEventsConsumerIT.java | 236 -------------------
.../KubernetesNamespacesConsumerIT.java | 139 -----------
.../integration/KubernetesPodsConsumerIT.java | 145 ------------
...KubernetesReplicationControllersConsumerIT.java | 134 -----------
.../KubernetesConfigMapsConsumerClusterwideIT.java | 62 +++++
...netesConfigMapsConsumerClusterwideLabelsIT.java | 59 +++++
.../KubernetesConfigMapsConsumerLabelsIT.java | 58 +++++
.../KubernetesConfigMapsConsumerNamespaceIT.java | 64 ++++++
...KubernetesConfigMapsConsumerResourceNameIT.java | 54 +++++
...KubernetesDeploymentsConsumerClusterwideIT.java | 63 +++++
...etesDeploymentsConsumerClusterwideLabelsIT.java | 68 ++++++
.../KubernetesDeploymentsConsumerLabelsIT.java | 72 ++++++
.../KubernetesDeploymentsConsumerNamespaceIT.java | 65 ++++++
...ubernetesDeploymentsConsumerResourceNameIT.java | 68 ++++++
.../KubernetesEventsConsumerClusterwideIT.java | 62 +++++
...ubernetesEventsConsumerClusterwideLabelsIT.java | 58 +++++
.../events/KubernetesEventsConsumerLabelsIT.java | 57 +++++
.../KubernetesEventsConsumerNamespaceIT.java | 51 ++++
.../KubernetesEventsConsumerResourceNameIT.java | 53 +++++
.../hpa/KubernetesHPAConsumerClusterwideIT.java | 54 +++++
.../KubernetesHPAConsumerClusterwideLabelsIT.java | 58 +++++
.../hpa/KubernetesHPAConsumerLabelsIT.java | 57 +++++
.../hpa/KubernetesHPAConsumerNamespaceIT.java | 51 ++++
.../hpa/KubernetesHPAConsumerResourceNameIT.java | 53 +++++
.../KubernetesNamespacesConsumerClusterwideIT.java | 72 ++++++
.../KubernetesNamespacesConsumerLabelsIT.java | 69 ++++++
...KubernetesNamespacesConsumerResourceNameIT.java | 68 ++++++
.../pods/KubernetesPodsConsumerClusterwideIT.java | 62 +++++
.../KubernetesPodsConsumerClusterwideLabelsIT.java | 68 ++++++
.../pods/KubernetesPodsConsumerLabelsIT.java | 72 ++++++
.../pods/KubernetesPodsConsumerNamespaceIT.java | 65 ++++++
.../pods/KubernetesPodsConsumerResourceNameIT.java | 67 ++++++
...eplicationControllersConsumerClusterwideIT.java | 63 +++++
...tionControllersConsumerClusterwideLabelsIT.java | 68 ++++++
...etesReplicationControllersConsumerLabelsIT.java | 72 ++++++
...sReplicationControllersConsumerNamespaceIT.java | 65 ++++++
...plicationControllersConsumerResourceNameIT.java | 68 ++++++
.../KubernetesServicesConsumerClusterwideIT.java | 62 +++++
...ernetesServicesConsumerClusterwideLabelsIT.java | 59 +++++
.../KubernetesServicesConsumerLabelsIT.java | 58 +++++
.../KubernetesServicesConsumerNamespaceIT.java | 64 ++++++
.../KubernetesServicesConsumerResourceNameIT.java | 54 +++++
.../support/KubernetesConsumerTestSupport.java | 256 +++++++++++++++++++++
.../producer/KubernetesConfigMapsProducerTest.java | 33 ++-
.../KubernetesResourcesQuotaProducerTest.java | 25 ++
.../KubernetesServiceAccountsProducerTest.java | 20 ++
72 files changed, 3155 insertions(+), 1043 deletions(-)
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-config-maps-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-config-maps-component.adoc
index f95085a5ca2..a4732bd6d6a 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-config-maps-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-config-maps-component.adoc
@@ -87,11 +87,9 @@ This operation returns a List of ConfigMaps from your cluster, using a label sel
[source,java]
--------------------------------------------------------------------------------
fromF("kubernetes-config-maps://%s?oauthToken=%s", host, authToken)
- .setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, constant("default"))
- .setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, constant("test"))
- .process(new KubernertesProcessor()).to("mock:result");
+ .process(new KubernetesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
@@ -101,7 +99,14 @@ fromF("kubernetes-config-maps://%s?oauthToken=%s", host, authToken)
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the config map test.
+This consumer returns a message per event received for all ConfigMaps from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch ConfigMaps with the specified label in any namespace.
+- `namespace` - Watch all ConfigMaps in the specified namespace.
+- `namespace` + `resourceName` - Watch the ConfigMap with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch ConfigMaps with the specified label in the given namespace.
== Using configmap properties function with Kubernetes
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-deployments-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-deployments-component.adoc
index 4972796ad5f..61ec2e8ab92 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-deployments-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-deployments-component.adoc
@@ -85,17 +85,26 @@ This operation returns a List of Deployments from your cluster, using a label se
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-deployments://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-deployments://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Deployment dp = exchange.getIn().getBody(Deployment.class);
- log.info("Got event with configmap name: " + dp.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with deployment name: " + dp.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the deployment test.
+This consumer returns a message per event received for all Deployments from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Deployments with the specified label in any namespace.
+- `namespace` - Watch all Deployments in the specified namespace.
+- `namespace` + `resourceName` - Watch the Deployment with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch Deployments with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-events-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-events-component.adoc
index 9a0472581c7..4b077688c5d 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-events-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-events-component.adoc
@@ -172,21 +172,26 @@ This operation expects two message headers which are `CamelKubernetesNamespaceNa
[source,java]
--------------------------------------------------------------------------------
fromF("kubernetes-events://%s?oauthToken=%s", host, authToken)
- .setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, constant("default"))
- .setHeader(KubernetesConstants.KUBERNETES_EVENT_NAME, constant("test"))
- .process(new KubernertesProcessor()).to("mock:result");
+ .process(new KubernetesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
- Event cm = exchange.getIn().getBody(Event.class);
- log.info("Got event with event name: " + cm.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ Event e = exchange.getIn().getBody(Event.class);
+ log.info("Got event with event name: " + e.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer returns a message per event received on the namespace "default" for the event "test". It also set the action (`io.fabric8.kubernetes.client.Watcher.Action`) in the message header `CamelKubernetesEventAction` and the timestamp (`long`) in the message header `CamelKubernetesEventTimestamp`.
+This consumer returns a message per event received in the whole cluster. It also set the action (`io.fabric8.kubernetes.client.Watcher.Action`) in the message header `CamelKubernetesEventAction` and the timestamp (`long`) in the message header `CamelKubernetesEventTimestamp`.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Events with the specified label in any namespace.
+- `namespace` - Watch all Events in the specified namespace.
+- `namespace` + `resourceName` - Watch the Event with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch Events with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-hpa-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-hpa-component.adoc
index 4fb77d78734..2a4b610fad5 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-hpa-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-hpa-component.adoc
@@ -84,8 +84,10 @@ This operation returns a List of HPAs from your cluster using a label selector (
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-hpa://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-hpa://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
@@ -95,8 +97,14 @@ fromF("kubernetes-hpa://%s?oauthToken=%s&namespace=default&resourceName=test", h
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the hpa test.
+This consumer returns a message per event received for all HorizontalPodAutoscalers from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+- `labelKey` + `labelValue` - Watch HorizontalPodAutoscalers with the specified label in any namespace.
+- `namespace` - Watch all HorizontalPodAutoscalers in the specified namespace.
+- `namespace` + `resourceName` - Watch the HorizontalPodAutoscaler with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch HorizontalPodAutoscalers with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc
index cdc51a54225..ffac912f014 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc
@@ -56,7 +56,7 @@ include::partial$component-endpoint-headers.adoc[]
[source,java]
--------------------------------------------------------------------------------
from("direct:list").
- toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listNamespaces").
+ toF("kubernetes-namespaces:///?kubernetesClient=#kubernetesClient&operation=listNamespaces").
to("mock:result");
--------------------------------------------------------------------------------
@@ -75,7 +75,7 @@ from("direct:listByLabels").process(new Processor() {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACES_LABELS, labels);
}
});
- toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listNamespacesByLabels").
+ toF("kubernetes-namespaces:///?kubernetesClient=#kubernetesClient&operation=listNamespacesByLabels").
to("mock:result");
--------------------------------------------------------------------------------
@@ -85,18 +85,25 @@ This operation returns a list of namespaces from your cluster, using a label sel
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-namespaces://%s?oauthToken=%s&namespace=default", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-namespaces://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Namespace ns = exchange.getIn().getBody(Namespace.class);
- log.info("Got event with configmap name: " + ns.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with namespace name: " + ns.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default.
+This consumer returns a message per event received for all Namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Namespaces with the specified label.
+- `resourceName` - Watch the Namespace with the specified name.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-nodes-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-nodes-component.adoc
index dfd104a1b88..572b4de2019 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-nodes-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-nodes-component.adoc
@@ -84,18 +84,25 @@ This operation returns a list of nodes from your cluster, using a label selector
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-nodes://%s?oauthToken=%s&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-nodes://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Node node = exchange.getIn().getBody(Node.class);
- log.info("Got event with configmap name: " + node.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with node name: " + node.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events for the node test.
+This consumer returns a message per event received for all Nodes in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Nodes with the specified label.
+- `resourceName` - Watch the Nodes with the specified name.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-pods-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-pods-component.adoc
index 2fe77fdfe07..e273179257f 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-pods-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-pods-component.adoc
@@ -84,18 +84,26 @@ This operation returns a list of pods from your cluster using a label selector (
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-pods://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-pods://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Pod pod = exchange.getIn().getBody(Pod.class);
- log.info("Got event with configmap name: " + pod.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with pod name: " + pod.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the pod test.
+This consumer returns a message per event received for all Pods from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Pods with the specified label in any namespace.
+- `namespace` - Watch all Pods in the specified namespace.
+- `namespace` + `resourceName` - Watch the Pod with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch Pods with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-replication-controllers-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-replication-controllers-component.adoc
index ef0a1bc841c..3d73e1ae51e 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-replication-controllers-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-replication-controllers-component.adoc
@@ -86,18 +86,27 @@ This operation returns a list of RCs from your cluster using a label selector (w
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-replication-controllers://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+fromF("kubernetes-replication-controllers://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
+
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
ReplicationController rc = exchange.getIn().getBody(ReplicationController.class);
- log.info("Got event with configmap name: " + rc.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with replication controller name: " + rc.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the rc test.
+This consumer returns a message per event received for all ReplicationControllers from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Replication Controllers with the specified label in any namespace.
+- `namespace` - Watch all Replication Controllers in the specified namespace.
+- `namespace` + `resourceName` - Watch the Replication Controller with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch Replication Controllers with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-services-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-services-component.adoc
index 46ac2a69340..a7e1a60518d 100644
--- a/components/camel-kubernetes/src/main/docs/kubernetes-services-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/kubernetes-services-component.adoc
@@ -83,19 +83,27 @@ This operation returns a list of services from your cluster using a label select
[source,java]
--------------------------------------------------------------------------------
-fromF("kubernetes-services://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new KubernertesProcessor()).to("mock:result");
+fromF("kubernetes-services://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor()).to("mock:result");
- public class KubernertesProcessor implements Processor {
+ public class KubernetesProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Service sv = exchange.getIn().getBody(Service.class);
- log.info("Got event with configmap name: " + sv.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with service name: " + sv.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the service test.
+This consumer returns a message per event received for all Services from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch Services with the specified label in any namespace.
+- `namespace` - Watch all Services in the specified namespace.
+- `namespace` + `resourceName` - Watch the Service with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch Services with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/docs/openshift-deploymentconfigs-component.adoc b/components/camel-kubernetes/src/main/docs/openshift-deploymentconfigs-component.adoc
index b9c8f02bfeb..52c8a83ec03 100644
--- a/components/camel-kubernetes/src/main/docs/openshift-deploymentconfigs-component.adoc
+++ b/components/camel-kubernetes/src/main/docs/openshift-deploymentconfigs-component.adoc
@@ -85,18 +85,27 @@ This operation returns a list of deployment configs from your cluster using a la
[source,java]
--------------------------------------------------------------------------------
-fromF("openshift-deploymentconfigs://%s?oauthToken=%s&namespace=default&resourceName=test", host, authToken).process(new OpenshiftProcessor()).to("mock:result");
+fromF("openshift-deploymentconfigs://%s?oauthToken=%s", host, authToken)
+ .process(new OpenshiftProcessor()).to("mock:result");
+
public class OpenshiftProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
DeploymentConfig dp = exchange.getIn().getBody(DeploymentConfig.class);
- log.info("Got event with configmap name: " + dp.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ log.info("Got event with deployment config name: " + dp.getMetadata().getName() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
}
}
--------------------------------------------------------------------------------
-This consumer will return a list of events on the namespace default for the deployment config test.
+This consumer returns a message per event received for all DeploymentConfigs from all namespaces in the cluster.
+
+You can narrow the scope of the consumer using the following query parameter combinations:
+
+- `labelKey` + `labelValue` - Watch DeploymentConfigs with the specified label in any namespace.
+- `namespace` - Watch all DeploymentConfigs in the specified namespace.
+- `namespace` + `resourceName` - Watch the DeploymentConfig with the specified name in the given namespace.
+- `namespace` + `labelKey` + `labelValue` - Watch DeploymentConfigs with the specified label in the given namespace.
include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsConsumer.java
index a7bb255514f..b2288699fd3 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsConsumer.java
@@ -24,10 +24,10 @@ import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
import org.apache.camel.component.kubernetes.KubernetesConstants;
import org.apache.camel.component.kubernetes.KubernetesHelper;
@@ -86,27 +86,42 @@ public class KubernetesConfigMapsConsumer extends DefaultConsumer {
@Override
public void run() {
-
- FilterWatchListDeletable<ConfigMap, ConfigMapList, Resource<ConfigMap>> w = null;
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w = getEndpoint().getKubernetesClient().configMaps().withLabel(
- getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
- }
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName())) {
- Resource<ConfigMap> configMapResource = getEndpoint()
- .getKubernetesClient().configMaps()
- .withName(getEndpoint().getKubernetesConfiguration().getResourceName());
- w = (FilterWatchListDeletable<ConfigMap, ConfigMapList, Resource<ConfigMap>>) configMapResource;
- }
- if (w == null) {
- throw new RuntimeCamelException("Consumer label key or consumer resource name need to be set.");
+ FilterWatchListDeletable<ConfigMap, ConfigMapList, Resource<ConfigMap>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().configMaps().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> client
+ = getEndpoint().getKubernetesClient().configMaps().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<ConfigMap, ConfigMapList, Resource<ConfigMap>>) client.withName(resourceName);
+ }
}
- watch = w.watch(new Watcher<ConfigMap>() {
+
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, ConfigMap resource) {
+ public void eventReceived(Action action, ConfigMap resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
index 1e94bc08546..a6ab9bba8b5 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
@@ -87,18 +87,28 @@ public class KubernetesConfigMapsProducer extends DefaultProducer {
}
protected void doList(Exchange exchange) {
- ConfigMapList configMapsList = getEndpoint().getKubernetesClient().configMaps().inAnyNamespace().list();
+ String namespace = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+ ConfigMapList configMapsList;
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ configMapsList = getEndpoint().getKubernetesClient().configMaps().inAnyNamespace().list();
+ } else {
+ configMapsList = getEndpoint().getKubernetesClient().configMaps().inNamespace(namespace).list();
+ }
prepareOutboundMessage(exchange, configMapsList.getItems());
}
protected void doListConfigMapsByLabels(Exchange exchange) {
+ String namespace = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, Map.class);
- ConfigMapList configMapsList = getEndpoint().getKubernetesClient()
- .configMaps()
- .inAnyNamespace()
- .withLabels(labels)
- .list();
+ ConfigMapList configMapsList;
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ configMapsList = getEndpoint().getKubernetesClient().configMaps().inAnyNamespace().withLabels(labels).list();
+ } else {
+ configMapsList = getEndpoint().getKubernetesClient().configMaps().inNamespace(namespace).withLabels(labels).list();
+ }
prepareOutboundMessage(exchange, configMapsList.getItems());
}
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsConsumer.java
index 247fbd488cb..3a2a7858229 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsConsumer.java
@@ -23,7 +23,8 @@ import io.fabric8.kubernetes.api.model.apps.DeploymentList;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -85,21 +86,43 @@ public class KubernetesDeploymentsConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<Deployment, DeploymentList, RollableScalableResource<Deployment>> w
- = getEndpoint().getKubernetesClient()
- .apps().deployments();
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<Deployment, DeploymentList, RollableScalableResource<Deployment>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().apps().deployments().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<Deployment, DeploymentList, RollableScalableResource<Deployment>> client
+ = getEndpoint().getKubernetesClient().apps().deployments().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<Deployment, DeploymentList, RollableScalableResource<Deployment>>) client
+ .withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<Deployment>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Deployment resource) {
+ public void eventReceived(Action action, Deployment resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsProducer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsProducer.java
index b851fbdb876..69481f4d22a 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsProducer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/deployments/KubernetesDeploymentsProducer.java
@@ -93,7 +93,14 @@ public class KubernetesDeploymentsProducer extends DefaultProducer {
}
protected void doList(Exchange exchange) {
- DeploymentList deploymentsList = getEndpoint().getKubernetesClient().apps().deployments().list();
+ String namespace = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+ DeploymentList deploymentsList;
+
+ if (ObjectHelper.isNotEmpty(namespace)) {
+ deploymentsList = getEndpoint().getKubernetesClient().apps().deployments().inNamespace(namespace).list();
+ } else {
+ deploymentsList = getEndpoint().getKubernetesClient().apps().deployments().list();
+ }
prepareOutboundMessage(exchange, deploymentsList.getItems());
}
@@ -104,18 +111,32 @@ public class KubernetesDeploymentsProducer extends DefaultProducer {
MixedOperation<Deployment, DeploymentList, RollableScalableResource<Deployment>> deployments = getEndpoint()
.getKubernetesClient().apps().deployments();
- DeploymentList deploymentList = deployments.withLabels(labels).list();
+ String namespace = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+ DeploymentList deploymentsList;
- prepareOutboundMessage(exchange, deploymentList.getItems());
+ if (ObjectHelper.isNotEmpty(namespace)) {
+ deploymentsList = deployments.inNamespace(namespace).withLabels(labels).list();
+ } else {
+ deploymentsList = deployments.withLabels(labels).list();
+ }
+
+ prepareOutboundMessage(exchange, deploymentsList.getItems());
}
protected void doGetDeployment(Exchange exchange) {
String deploymentName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENT_NAME, String.class);
+ String namespace = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(deploymentName)) {
LOG.error("Get a specific Deployment require specify a Deployment name");
throw new IllegalArgumentException("Get a specific Deployment require specify a Deployment name");
}
- Deployment deployment = getEndpoint().getKubernetesClient().apps().deployments().withName(deploymentName).get();
+ Deployment deployment;
+ if (ObjectHelper.isNotEmpty(namespace)) {
+ deployment = getEndpoint().getKubernetesClient().apps().deployments()
+ .inNamespace(namespace).withName(deploymentName).get();
+ } else {
+ deployment = getEndpoint().getKubernetesClient().apps().deployments().withName(deploymentName).get();
+ }
prepareOutboundMessage(exchange, deployment);
}
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/events/KubernetesEventsConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/events/KubernetesEventsConsumer.java
index 5cb017280ef..ed2ddb8cf3b 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/events/KubernetesEventsConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/events/KubernetesEventsConsumer.java
@@ -24,10 +24,10 @@ import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
import org.apache.camel.component.kubernetes.KubernetesConstants;
import org.apache.camel.component.kubernetes.KubernetesHelper;
@@ -86,23 +86,38 @@ public class KubernetesEventsConsumer extends DefaultConsumer {
@Override
public void run() {
-
- FilterWatchListDeletable<Event, EventList, Resource<Event>> w = null;
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w = getEndpoint().getKubernetesClient().events().v1().events().withLabel(
- getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
- }
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName())) {
- Resource<Event> eventResource = getEndpoint()
- .getKubernetesClient().events().v1().events()
- .withName(getEndpoint().getKubernetesConfiguration().getResourceName());
- w = (FilterWatchListDeletable<Event, EventList, Resource<Event>>) eventResource;
- }
- if (w == null) {
- throw new RuntimeCamelException("Consumer label key or consumer resource name need to be set.");
+ FilterWatchListDeletable<Event, EventList, Resource<Event>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().events().v1().events().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<Event, EventList, Resource<Event>> client
+ = getEndpoint().getKubernetesClient().events().v1().events().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<Event, EventList, Resource<Event>>) client.withName(resourceName);
+ }
}
+
watch = w.watch(new Watcher<>() {
@Override
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/hpa/KubernetesHPAConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/hpa/KubernetesHPAConsumer.java
index 53ba9b36953..c351853b615 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/hpa/KubernetesHPAConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/hpa/KubernetesHPAConsumer.java
@@ -23,7 +23,8 @@ import io.fabric8.kubernetes.api.model.autoscaling.v1.HorizontalPodAutoscalerLis
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -85,25 +86,44 @@ public class KubernetesHPAConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<HorizontalPodAutoscaler, HorizontalPodAutoscalerList, Resource<HorizontalPodAutoscaler>> w
- = getEndpoint()
- .getKubernetesClient().autoscaling().v1().horizontalPodAutoscalers();
-
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getNamespace(), w::inNamespace);
-
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<HorizontalPodAutoscaler, HorizontalPodAutoscalerList, Resource<HorizontalPodAutoscaler>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().autoscaling().v1().horizontalPodAutoscalers().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<HorizontalPodAutoscaler, HorizontalPodAutoscalerList, Resource<HorizontalPodAutoscaler>> client
+ = getEndpoint().getKubernetesClient().autoscaling().v1().horizontalPodAutoscalers()
+ .inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<HorizontalPodAutoscaler, HorizontalPodAutoscalerList, Resource<HorizontalPodAutoscaler>>) client
+ .withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<HorizontalPodAutoscaler>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(
- io.fabric8.kubernetes.client.Watcher.Action action, HorizontalPodAutoscaler resource) {
+ public void eventReceived(Action action, HorizontalPodAutoscaler resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/job/KubernetesJobProducer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/job/KubernetesJobProducer.java
index 2a8cb7eace6..12f46b1a760 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/job/KubernetesJobProducer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/job/KubernetesJobProducer.java
@@ -153,9 +153,9 @@ public class KubernetesJobProducer extends DefaultProducer {
String.format("%s a specific job require specify a namespace name", operationName));
}
if (ObjectHelper.isEmpty(jobSpec)) {
- LOG.error("{} a specific job require specify a hpa spec bean", operationName);
+ LOG.error("{} a specific job require specify a job spec bean", operationName);
throw new IllegalArgumentException(
- String.format("%s a specific job require specify a hpa spec bean", operationName));
+ String.format("%s a specific job require specify a job spec bean", operationName));
}
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_JOB_LABELS, Map.class);
JobBuilder jobCreatingBuilder = new JobBuilder();
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/namespaces/KubernetesNamespacesConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/namespaces/KubernetesNamespacesConsumer.java
index 768ee1b1e1d..67b7844f5fa 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/namespaces/KubernetesNamespacesConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/namespaces/KubernetesNamespacesConsumer.java
@@ -88,12 +88,21 @@ public class KubernetesNamespacesConsumer extends DefaultConsumer {
NonNamespaceOperation<Namespace, NamespaceList, Resource<Namespace>> w
= getEndpoint().getKubernetesClient().namespaces();
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getNamespace(), w::withName);
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = (NonNamespaceOperation<Namespace, NamespaceList, Resource<Namespace>>) w.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (NonNamespaceOperation<Namespace, NamespaceList, Resource<Namespace>>) getEndpoint().getKubernetesClient()
+ .namespaces().withName(resourceName);
+ }
- watch = w.watch(new Watcher<Namespace>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Namespace resource) {
+ public void eventReceived(Action action, Namespace resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/nodes/KubernetesNodesConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/nodes/KubernetesNodesConsumer.java
index e5fe5a4daef..026f8033eb9 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/nodes/KubernetesNodesConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/nodes/KubernetesNodesConsumer.java
@@ -86,18 +86,21 @@ public class KubernetesNodesConsumer extends DefaultConsumer {
@Override
public void run() {
NonNamespaceOperation<Node, NodeList, Resource<Node>> w = getEndpoint().getKubernetesClient().nodes();
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
- }
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = (NonNamespaceOperation<Node, NodeList, Resource<Node>>) w.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (NonNamespaceOperation<Node, NodeList, Resource<Node>>) w.withName(resourceName);
+ }
- watch = w.watch(new Watcher<Node>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Node resource) {
+ public void eventReceived(Action action, Node resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/pods/KubernetesPodsConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/pods/KubernetesPodsConsumer.java
index 74acf903f53..17909786da6 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/pods/KubernetesPodsConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/pods/KubernetesPodsConsumer.java
@@ -23,7 +23,8 @@ import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.PodResource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -85,22 +86,42 @@ public class KubernetesPodsConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<Pod, PodList, PodResource> w = getEndpoint().getKubernetesClient().pods();
-
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getNamespace(), w::inNamespace);
-
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<Pod, PodList, PodResource> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().pods().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<Pod, PodList, PodResource> client
+ = getEndpoint().getKubernetesClient().pods().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<Pod, PodList, PodResource>) client.withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<Pod>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Pod resource) {
+ public void eventReceived(Action action, Pod resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/KubernetesReplicationControllersConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/KubernetesReplicationControllersConsumer.java
index c6bc153a924..fe3c22afc8e 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/KubernetesReplicationControllersConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/KubernetesReplicationControllersConsumer.java
@@ -23,7 +23,8 @@ import io.fabric8.kubernetes.api.model.ReplicationControllerList;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -85,23 +86,43 @@ public class KubernetesReplicationControllersConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<ReplicationController, ReplicationControllerList, RollableScalableResource<ReplicationController>> w
- = getEndpoint()
- .getKubernetesClient().replicationControllers();
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getNamespace(), w::inNamespace);
-
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<ReplicationController, ReplicationControllerList, RollableScalableResource<ReplicationController>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().replicationControllers().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<ReplicationController, ReplicationControllerList, RollableScalableResource<ReplicationController>> client
+ = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<ReplicationController, ReplicationControllerList, RollableScalableResource<ReplicationController>>) client
+ .withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<ReplicationController>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, ReplicationController resource) {
+ public void eventReceived(Action action, ReplicationController resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/resources_quota/KubernetesResourcesQuotaProducer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/resources_quota/KubernetesResourcesQuotaProducer.java
index 562d23391fb..97da82798ab 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/resources_quota/KubernetesResourcesQuotaProducer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/resources_quota/KubernetesResourcesQuotaProducer.java
@@ -25,8 +25,6 @@ import io.fabric8.kubernetes.api.model.ResourceQuotaBuilder;
import io.fabric8.kubernetes.api.model.ResourceQuotaList;
import io.fabric8.kubernetes.api.model.ResourceQuotaSpec;
import io.fabric8.kubernetes.api.model.StatusDetails;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
-import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import org.apache.camel.Exchange;
import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
@@ -63,7 +61,7 @@ public class KubernetesResourcesQuotaProducer extends DefaultProducer {
doList(exchange);
break;
- case KubernetesOperations.LIST_SECRETS_BY_LABELS_OPERATION:
+ case KubernetesOperations.LIST_RESOURCES_QUOTA_BY_LABELS_OPERATION:
doListResourceQuotasByLabels(exchange);
break;
@@ -100,19 +98,9 @@ public class KubernetesResourcesQuotaProducer extends DefaultProducer {
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
ResourceQuotaList resList;
if (!ObjectHelper.isEmpty(namespaceName)) {
- NonNamespaceOperation<ResourceQuota, ResourceQuotaList, Resource<ResourceQuota>> resQuota
- = getEndpoint().getKubernetesClient().resourceQuotas().inNamespace(namespaceName);
- for (Map.Entry<String, String> entry : labels.entrySet()) {
- resQuota.withLabel(entry.getKey(), entry.getValue());
- }
- resList = resQuota.list();
+ resList = getEndpoint().getKubernetesClient().resourceQuotas().inNamespace(namespaceName).withLabels(labels).list();
} else {
- MixedOperation<ResourceQuota, ResourceQuotaList, Resource<ResourceQuota>> resQuota
- = getEndpoint().getKubernetesClient().resourceQuotas();
- for (Map.Entry<String, String> entry : labels.entrySet()) {
- resQuota.withLabel(entry.getKey(), entry.getValue());
- }
- resList = resQuota.list();
+ resList = getEndpoint().getKubernetesClient().resourceQuotas().inAnyNamespace().withLabels(labels).list();
}
prepareOutboundMessage(exchange, resList.getItems());
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsProducer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsProducer.java
index d15cfd85809..16fc183f8e5 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsProducer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsProducer.java
@@ -63,7 +63,7 @@ public class KubernetesServiceAccountsProducer extends DefaultProducer {
doListServiceAccountsByLabels(exchange);
break;
- case KubernetesOperations.GET_SECRET_OPERATION:
+ case KubernetesOperations.GET_SERVICE_ACCOUNT_OPERATION:
doGetServiceAccount(exchange);
break;
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/services/KubernetesServicesConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/services/KubernetesServicesConsumer.java
index c6ae8759024..637e08b997f 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/services/KubernetesServicesConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/services/KubernetesServicesConsumer.java
@@ -23,7 +23,8 @@ import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.ServiceResource;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@@ -85,22 +86,43 @@ public class KubernetesServicesConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<Service, ServiceList, ServiceResource<Service>> w = getEndpoint().getKubernetesClient().services();
-
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getNamespace(), w::inNamespace);
-
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<Service, ServiceList, ServiceResource<Service>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().services().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<Service, ServiceList, ServiceResource<Service>> client
+ = getEndpoint().getKubernetesClient().services().inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<Service, ServiceList, ServiceResource<Service>>) client
+ .withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<Service>() {
+ watch = w.watch(new Watcher<>() {
@Override
- public void eventReceived(io.fabric8.kubernetes.client.Watcher.Action action, Service resource) {
+ public void eventReceived(Action action, Service resource) {
Exchange exchange = createExchange(false);
exchange.getIn().setBody(resource);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION, action);
diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/OpenshiftDeploymentConfigsConsumer.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/OpenshiftDeploymentConfigsConsumer.java
index 934f94c06d2..685fb7e11a0 100644
--- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/OpenshiftDeploymentConfigsConsumer.java
+++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/OpenshiftDeploymentConfigsConsumer.java
@@ -21,7 +21,8 @@ import java.util.concurrent.ExecutorService;
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.WatcherException;
-import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.FilterWatchListDeletable;
+import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.openshift.api.model.DeploymentConfig;
import io.fabric8.openshift.api.model.DeploymentConfigList;
import io.fabric8.openshift.client.OpenShiftClient;
@@ -86,19 +87,41 @@ public class OpenshiftDeploymentConfigsConsumer extends DefaultConsumer {
@Override
public void run() {
- MixedOperation<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>> w
- = getEndpoint().getKubernetesClient()
- .adapt(OpenShiftClient.class)
- .deploymentConfigs();
- if (ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelKey())
- && ObjectHelper.isNotEmpty(getEndpoint().getKubernetesConfiguration().getLabelValue())) {
- w.withLabel(getEndpoint().getKubernetesConfiguration().getLabelKey(),
- getEndpoint().getKubernetesConfiguration().getLabelValue());
+ FilterWatchListDeletable<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>> w;
+
+ /*
+ Valid options are (according to how the client can be constructed):
+ - inAnyNamespace
+ - inAnyNamespace + withLabel
+ - inNamespace
+ - inNamespace + withLabel
+ - inNamespace + withName
+ */
+ String namespace = getEndpoint().getKubernetesConfiguration().getNamespace();
+ String labelKey = getEndpoint().getKubernetesConfiguration().getLabelKey();
+ String labelValue = getEndpoint().getKubernetesConfiguration().getLabelValue();
+ String resourceName = getEndpoint().getKubernetesConfiguration().getResourceName();
+
+ if (ObjectHelper.isEmpty(namespace)) {
+ w = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).deploymentConfigs().inAnyNamespace();
+
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = w.withLabel(labelKey, labelValue);
+ }
+ } else {
+ final NonNamespaceOperation<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>> client
+ = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).deploymentConfigs()
+ .inNamespace(namespace);
+ w = client;
+ if (ObjectHelper.isNotEmpty(labelKey) && ObjectHelper.isNotEmpty(labelValue)) {
+ w = client.withLabel(labelKey, labelValue);
+ } else if (ObjectHelper.isNotEmpty(resourceName)) {
+ w = (FilterWatchListDeletable<DeploymentConfig, DeploymentConfigList, DeployableScalableResource<DeploymentConfig>>) client
+ .withName(resourceName);
+ }
}
- ObjectHelper.ifNotEmpty(getEndpoint().getKubernetesConfiguration().getResourceName(), w::withName);
-
- watch = w.watch(new Watcher<DeploymentConfig>() {
+ watch = w.watch(new Watcher<>() {
@Override
public void eventReceived(Action action, DeploymentConfig resource) {
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesConfigMapsConsumerIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesConfigMapsConsumerIT.java
deleted file mode 100644
index 29638e6d52b..00000000000
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesConfigMapsConsumerIT.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.kubernetes.consumer.integration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import io.fabric8.kubernetes.api.model.ConfigMap;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.KubernetesConstants;
-import org.apache.camel.component.kubernetes.KubernetesTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@EnabledIfSystemProperties({
- @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
-})
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class KubernetesConfigMapsConsumerIT extends KubernetesTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- public void configureMock() {
- mockResultEndpoint.expectedMessageCount(3);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
- "MODIFIED", "MODIFIED");
- }
-
- @BeforeEach
- public void waitForSettle() throws InterruptedException {
- Thread.sleep(1000);
- }
-
- @Test
- @Order(1)
- void createConfigMapWithProperties() {
- configureMock();
-
- Exchange ex = template.request("direct:createConfigmap", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test");
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, labels);
- HashMap<String, String> configMapData = new HashMap<>();
- configMapData.put("test", "test");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_DATA, configMapData);
- });
-
- Message message = ex.getMessage();
-
- assertNotNull(message);
- assertNotNull(message.getBody());
- }
-
- @Test
- @Order(2)
- void createConfigMap() {
- configureMock();
-
- Exchange ex = template.request("direct:createConfigmap", exchange -> {
- exchange.getIn().removeHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS);
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test1");
- HashMap<String, String> configMapData = new HashMap<>();
- configMapData.put("test", "test");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_DATA, configMapData);
- });
-
- Message message = ex.getMessage();
-
- assertNotNull(message);
- assertNotNull(message.getBody());
- }
-
- @Test
- @Order(3)
- void updateConfigMap() {
- configureMock();
-
- Map<String, String> configMapData = Map.of("test1", "test1");
- Exchange ex = template.request("direct:updateConfigmap", exchange -> {
- exchange.getIn().removeHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS);
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "test1");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_DATA, configMapData);
- });
-
- Message message = ex.getMessage();
-
- assertNotNull(message);
- ConfigMap result = ex.getMessage().getBody(ConfigMap.class);
-
- assertEquals("default", result.getMetadata().getNamespace());
- assertEquals("test1", result.getMetadata().getName());
- assertEquals(configMapData, result.getData());
- }
-
- @ParameterizedTest
- @Order(4)
- @ValueSource(strings = { "test", "test1" })
- void deleteConfigMaps(String configMapName) {
- Exchange ex = template.request("direct:deleteConfigmap", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, configMapName);
- });
-
- Message message = ex.getMessage();
-
- assertNotNull(message);
-
- // To avoid a NPE if unable to convert for any reason
- assertNotNull(message.getBody());
- boolean cmDeleted = message.getBody(Boolean.class);
- assertTrue(cmDeleted);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:createConfigmap")
- .toF("kubernetes-config-maps://%s?oauthToken=%s&operation=createConfigMap", host,
- authToken);
- from("direct:updateConfigmap")
- .toF("kubernetes-config-maps://%s?oauthToken=%s&operation=updateConfigMap", host,
- authToken);
-
- from("direct:deleteConfigmap")
- .toF("kubernetes-config-maps://%s?oauthToken=%s&operation=deleteConfigMap", host,
- authToken);
-
- fromF("kubernetes-config-maps://%s?oauthToken=%s&operation=listConfigMaps", host, authToken)
- .process(new KubernetesProcessor()).to(mockResultEndpoint);
- }
- };
- }
-
- public class KubernetesProcessor implements Processor {
- @Override
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- ConfigMap cm = exchange.getIn().getBody(ConfigMap.class);
-
- log.info("Got event with configmap name: {} and action {}", cm.getMetadata().getName(),
- in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
- }
- }
-}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesEventsConsumerIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesEventsConsumerIT.java
deleted file mode 100644
index ce98f445f3e..00000000000
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesEventsConsumerIT.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.kubernetes.consumer.integration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import io.fabric8.kubernetes.api.model.MicroTimeBuilder;
-import io.fabric8.kubernetes.api.model.ObjectReferenceBuilder;
-import io.fabric8.kubernetes.api.model.events.v1.Event;
-import io.fabric8.kubernetes.api.model.events.v1.EventBuilder;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.KubernetesConstants;
-import org.apache.camel.component.kubernetes.KubernetesTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@EnabledIfSystemProperties({
- @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
-})
-@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class KubernetesEventsConsumerIT extends KubernetesTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- @BeforeEach
- void beforeEach() {
- MockEndpoint.resetMocks(context);
- }
-
- private void setupFullEventWithHeaders(Exchange exchange) {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_NAME, "test");
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENTS_LABELS, labels);
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_TIME, "2022-10-10T17:30:47.986439Z");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION_PRODUCER, "Some Action");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_TYPE, "Warning");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REASON, "Some Reason");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_NOTE, "Some Note");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REGARDING,
- new ObjectReferenceBuilder().withName("Some Regarding").build());
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_RELATED,
- new ObjectReferenceBuilder().withName("Some Related").build());
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REPORTING_CONTROLLER, "Some-Reporting-Controller");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REPORTING_INSTANCE, "Some-Reporting-Instance");
-
- }
-
- @Test
- @Order(1)
- void createFullEventWithHeaders() throws Exception {
- mockResultEndpoint.expectedMessageCount(1);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED");
- Exchange ex = template.request("direct:createEvent", this::setupFullEventWithHeaders);
-
- assertNotNull(ex);
- assertNotNull(ex.getMessage());
- assertNotNull(ex.getMessage().getBody());
-
- Event evt = ex.getMessage().getBody(Event.class);
- assertEquals("test", evt.getMetadata().getName());
- assertEquals(Map.of("this", "rocks"), evt.getMetadata().getLabels());
- assertEquals("default", evt.getMetadata().getNamespace());
- assertEquals(new MicroTimeBuilder().withTime("2022-10-10T17:30:47.986439Z").build(), evt.getEventTime());
- assertEquals("Some Action", evt.getAction());
- assertEquals("Warning", evt.getType());
- assertEquals("Some Reason", evt.getReason());
- assertEquals("Some Note", evt.getNote());
- assertEquals("Some Regarding", evt.getRegarding().getName());
- assertEquals("Some Related", evt.getRelated().getName());
- assertEquals("Some-Reporting-Controller", evt.getReportingController());
- assertEquals("Some-Reporting-Instance", evt.getReportingInstance());
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- private void setupMinimalEventWithHeaders(Exchange exchange) {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_NAME, "test1");
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENTS_LABELS, labels);
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION_PRODUCER, "Some Action");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_TYPE, "Normal");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REASON, "Some Reason");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REPORTING_CONTROLLER, "Some-Reporting-Controller");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_REPORTING_INSTANCE, "Some-Reporting-Instance");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_TIME, "2022-10-10T17:30:47.986439Z");
- }
-
- @Test
- @Order(2)
- void createMinimalEventWithHeaders() throws Exception {
- mockResultEndpoint.expectedMessageCount(1);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED");
- Exchange ex = template.request("direct:createEvent", this::setupMinimalEventWithHeaders);
-
- assertNotNull(ex);
- assertNotNull(ex.getMessage());
- assertNotNull(ex.getMessage().getBody());
-
- Event evt = ex.getMessage().getBody(Event.class);
- assertEquals("test1", evt.getMetadata().getName());
- assertEquals(Map.of("this", "rocks"), evt.getMetadata().getLabels());
- assertEquals("default", evt.getMetadata().getNamespace());
- assertNotNull(evt.getEventTime());
- assertEquals("Some Action", evt.getAction());
- assertEquals("Normal", evt.getType());
- assertEquals("Some Reason", evt.getReason());
- assertEquals("Some-Reporting-Controller", evt.getReportingController());
- assertEquals("Some-Reporting-Instance", evt.getReportingInstance());
- assertEquals(new MicroTimeBuilder().withTime("2022-10-10T17:30:47.986439Z").build(), evt.getEventTime());
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- private void setupMinimalEventWithBuilder(Exchange exchange) {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_NAME, "test2");
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENTS_LABELS, labels);
- exchange.getIn().setBody(
- new EventBuilder()
- .withAction("Some Action")
- .withType("Normal")
- .withReason("Some Reason")
- .withReportingController("Some-Reporting-Controller")
- .withReportingInstance("Some-Reporting-Instance")
- .withEventTime(new MicroTimeBuilder().withTime("2022-10-10T19:33:47.986439Z").build()));
- }
-
- @Test
- @Order(3)
- void createMinimalEventWithBuilder() throws Exception {
- mockResultEndpoint.expectedMessageCount(1);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED");
- Exchange ex = template.request("direct:createEvent", this::setupMinimalEventWithBuilder);
-
- assertNotNull(ex);
- assertNotNull(ex.getMessage());
- assertNotNull(ex.getMessage().getBody());
-
- Event evt = ex.getMessage().getBody(Event.class);
- assertEquals("test2", evt.getMetadata().getName());
- assertEquals(Map.of("this", "rocks"), evt.getMetadata().getLabels());
- assertEquals("default", evt.getMetadata().getNamespace());
- assertNotNull(evt.getEventTime());
- assertEquals("Some Action", evt.getAction());
- assertEquals("Normal", evt.getType());
- assertEquals("Some Reason", evt.getReason());
- assertEquals("Some-Reporting-Controller", evt.getReportingController());
- assertEquals("Some-Reporting-Instance", evt.getReportingInstance());
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @ParameterizedTest
- @ValueSource(strings = { "test", "test1", "test2" })
- @Order(4)
- void deleteEvent(String eventName) throws Exception {
- mockResultEndpoint.expectedMessageCount(1);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "DELETED");
- Exchange ex = template.request("direct:deleteEvent", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_EVENT_NAME, eventName);
- });
-
- boolean eventDeleted = ex.getMessage().getBody(Boolean.class);
-
- assertTrue(eventDeleted);
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:createEvent").toF("kubernetes-events://%s?oauthToken=%s&operation=createEvent", host, authToken);
- from("direct:deleteEvent").toF("kubernetes-events://%s?oauthToken=%s&operation=deleteEvent", host, authToken);
- fromF("kubernetes-events://%s?oauthToken=%s&namespace=default&labelKey=this&labelValue=rocks", host, authToken)
- .process(new KubernetesProcessor())
- .to(mockResultEndpoint);
- }
- };
- }
-
- public class KubernetesProcessor implements Processor {
- @Override
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- Event event = exchange.getIn().getBody(Event.class);
- log.info("Got event with event name: {} and action {}", event.getMetadata().getName(),
- in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
- }
- }
-}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesNamespacesConsumerIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesNamespacesConsumerIT.java
deleted file mode 100644
index 87e683661b7..00000000000
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesNamespacesConsumerIT.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.kubernetes.consumer.integration;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-import io.fabric8.kubernetes.api.model.Namespace;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.KubernetesConstants;
-import org.apache.camel.component.kubernetes.KubernetesTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@EnabledIfSystemProperties({
- @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
-})
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class KubernetesNamespacesConsumerIT extends KubernetesTestSupport {
- private static final String TEST_NAME_SPACE = "test" + ThreadLocalRandom.current().nextInt(1, 100);
-
- @EndpointInject("mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- @Test
- @Order(1)
- void createPod() {
- mockResultEndpoint.expectedMessageCount(5);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
- "MODIFIED", "MODIFIED", "MODIFIED", "DELETED");
-
- Exchange ex = template.request("direct:createNamespace", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, TEST_NAME_SPACE);
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, labels);
- });
-
- Namespace ns = ex.getMessage().getBody(Namespace.class);
-
- assertNotNull(ns);
- assertEquals(TEST_NAME_SPACE, ns.getMetadata().getName());
- }
-
- @Test
- @Order(2)
- void listByLabels() {
- Exchange ex = template.request("direct:listByLabels", exchange -> {
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, labels);
- });
-
- boolean testNamespaceExists = false;
-
- for (Object o : ex.getMessage().getBody(List.class)) {
- Namespace namespace = (Namespace) o;
- if (TEST_NAME_SPACE.equalsIgnoreCase(namespace.getMetadata().getName())) {
- testNamespaceExists = true;
- }
- }
-
- assertTrue(testNamespaceExists);
- }
-
- @Test
- @Order(3)
- void deletePod() throws Exception {
- Exchange ex = template.request("direct:deleteNamespace",
- exchange -> exchange.getIn()
- .setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, TEST_NAME_SPACE));
-
- Object body = ex.getMessage().getBody();
- assertNotNull(body);
-
- boolean nsDeleted = ex.getMessage().getBody(Boolean.class);
-
- assertTrue(nsDeleted);
-
- mockResultEndpoint.assertIsSatisfied(5100);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:listByLabels").toF("kubernetes-namespaces://%s?oauthToken=%s&operation=listNamespacesByLabels",
- host, authToken);
- from("direct:createNamespace").toF("kubernetes-namespaces://%s?oauthToken=%s&operation=createNamespace", host,
- authToken);
- from("direct:deleteNamespace").toF("kubernetes-namespaces://%s?oauthToken=%s&operation=deleteNamespace", host,
- authToken);
- fromF("kubernetes-namespaces://%s?oauthToken=%s", host, authToken).process(new KubernetesProcessor())
- .to(mockResultEndpoint);
- }
- };
- }
-
- public class KubernetesProcessor implements Processor {
- @Override
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- log.info("Got event with body: {} and action {}", in.getBody(),
- in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
- }
- }
-}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesPodsConsumerIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesPodsConsumerIT.java
deleted file mode 100644
index 09b66b51e5b..00000000000
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesPodsConsumerIT.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.kubernetes.consumer.integration;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-import io.fabric8.kubernetes.api.model.Container;
-import io.fabric8.kubernetes.api.model.ContainerPort;
-import io.fabric8.kubernetes.api.model.Pod;
-import io.fabric8.kubernetes.api.model.PodSpec;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.KubernetesConstants;
-import org.apache.camel.component.kubernetes.KubernetesTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@EnabledIfSystemProperties({
- @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
-})
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class KubernetesPodsConsumerIT extends KubernetesTestSupport {
- private static final String TEST_POD_NAME = "test" + ThreadLocalRandom.current().nextInt(1, 100);
-
- @EndpointInject("mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- private void setupPod(Exchange exchange) {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_NAME, TEST_POD_NAME);
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PODS_LABELS, labels);
- PodSpec podSpec = new PodSpec();
- podSpec.setHostname("localhost");
- Container cont = new Container();
- cont.setImage("docker.io/jboss/wildfly:latest");
- cont.setName("pippo");
-
- List<ContainerPort> containerPort = new ArrayList<>();
- ContainerPort port = new ContainerPort();
- port.setHostIP("0.0.0.0");
- port.setHostPort(8080);
- port.setContainerPort(8080);
-
- containerPort.add(port);
-
- cont.setPorts(containerPort);
-
- List<Container> list = new ArrayList<>();
- list.add(cont);
-
- podSpec.setContainers(list);
-
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_SPEC, podSpec);
- }
-
- @Test
- @Order(1)
- void createPod() throws Exception {
- mockResultEndpoint.expectedMessageCount(2);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
- "ADDED", "ADDED");
- Exchange ex = template.request("direct:createPod", this::setupPod);
-
- assertNotNull(ex);
- assertNotNull(ex.getMessage());
- assertNotNull(ex.getMessage().getBody());
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @Test
- @Order(2)
- void deletePod() throws Exception {
- mockResultEndpoint.expectedMessageCount(1);
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION,
- "ADDED", "ADDED", "ADDED");
- Exchange ex = template.request("direct:deletePod", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_NAME, TEST_POD_NAME);
- });
-
- boolean podDeleted = ex.getMessage().getBody(Boolean.class);
-
- assertTrue(podDeleted);
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:createPod").toF("kubernetes-pods://%s?oauthToken=%s&operation=createPod", host, authToken);
- from("direct:deletePod").toF("kubernetes-pods://%s?oauthToken=%s&operation=deletePod", host, authToken);
- fromF("kubernetes-pods://%s?oauthToken=%s&namespace=default&labelKey=this&labelValue=rocks", host, authToken)
- .process(new KubernetesProcessor())
- .to(mockResultEndpoint);
- }
- };
- }
-
- public class KubernetesProcessor implements Processor {
- @Override
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- Pod pod = exchange.getIn().getBody(Pod.class);
- log.info("Got event with pod name: {} and action {}", pod.getMetadata().getName(),
- in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
- }
- }
-}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesReplicationControllersConsumerIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesReplicationControllersConsumerIT.java
deleted file mode 100644
index cd76c398ba7..00000000000
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/KubernetesReplicationControllersConsumerIT.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.kubernetes.consumer.integration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import io.fabric8.kubernetes.api.model.PodTemplateSpec;
-import io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder;
-import io.fabric8.kubernetes.api.model.ReplicationController;
-import io.fabric8.kubernetes.api.model.ReplicationControllerSpec;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.KubernetesConstants;
-import org.apache.camel.component.kubernetes.KubernetesTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@EnabledIfSystemProperties({
- @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
- @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
-})
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class KubernetesReplicationControllersConsumerIT extends KubernetesTestSupport {
-
- @EndpointInject("mock:result")
- protected MockEndpoint mockResultEndpoint;
-
- @BeforeEach
- public void waitForSettle() throws InterruptedException {
- Thread.sleep(1000);
- }
-
- @Test
- @Order(1)
- void createReplicationController() throws Exception {
- mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
- "MODIFIED", "MODIFIED");
-
- Exchange ex = template.request("direct:createReplicationController", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME, "test");
- Map<String, String> labels = new HashMap<>();
- labels.put("this", "rocks");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS, labels);
- ReplicationControllerSpec rcSpec = new ReplicationControllerSpec();
- rcSpec.setReplicas(2);
- PodTemplateSpecBuilder builder = new PodTemplateSpecBuilder();
- PodTemplateSpec t = builder.withNewMetadata().withName("nginx-template").addToLabels("server", "nginx")
- .endMetadata().withNewSpec().addNewContainer()
- .withName("wildfly").withImage("jboss/wildfly").addNewPort().withContainerPort(80).endPort().endContainer()
- .endSpec().build();
- rcSpec.setTemplate(t);
- Map<String, String> selectorMap = new HashMap<>();
- selectorMap.put("server", "nginx");
- rcSpec.setSelector(selectorMap);
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_SPEC, rcSpec);
- });
-
- ReplicationController rc = ex.getMessage().getBody(ReplicationController.class);
-
- assertEquals("test", rc.getMetadata().getName());
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @Test
- @Order(2)
- void deleteReplicationController() throws Exception {
- Exchange ex = template.request("direct:deleteReplicationController", exchange -> {
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
- exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME, "test");
- });
-
- boolean rcDeleted = ex.getMessage().getBody(Boolean.class);
-
- assertTrue(rcDeleted);
-
- mockResultEndpoint.assertIsSatisfied();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:createReplicationController").toF(
- "kubernetes-replication-controllers://%s?oauthToken=%s&operation=createReplicationController", host,
- authToken);
- from("direct:deleteReplicationController").toF(
- "kubernetes-replication-controllers://%s?oauthToken=%s&operation=deleteReplicationController", host,
- authToken);
- fromF("kubernetes-replication-controllers://%s?oauthToken=%s&resourceName=wildfly", host, authToken)
- .process(new KubernetesProcessor()).to(mockResultEndpoint);
- }
- };
- }
-
- public class KubernetesProcessor implements Processor {
- @Override
- public void process(Exchange exchange) {
- Message in = exchange.getIn();
- log.info("Got event with body: {} and action {}", in.getBody(),
- in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
- }
- }
-}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideIT.java
new file mode 100644
index 00000000000..bf9c46ecb34
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideIT.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.configmaps;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesConfigMapsConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createConfigMap(ns1, "cm1", null);
+ createConfigMap(ns2, "cm2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("cm1")), hasItem(containsString("cm2"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-config-maps://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..63514102ddb
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerClusterwideLabelsIT.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.configmaps;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesConfigMapsConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() throws Exception {
+ result.expectedBodiesReceivedInAnyOrder(
+ "ConfigMap cm1 " + ns1 + " ADDED",
+ "ConfigMap cm2 " + ns2 + " ADDED");
+
+ createConfigMap(ns1, "cm1", LABELS);
+ createConfigMap(ns2, "cm2", LABELS);
+ createConfigMap(ns2, "cm3", Map.of("otherKey", "otherValue"));
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-config-maps://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerLabelsIT.java
new file mode 100644
index 00000000000..20beb1dc202
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerLabelsIT.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.configmaps;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesConfigMapsConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() throws Exception {
+ result.expectedBodiesReceived("ConfigMap cm4 " + ns2 + " ADDED");
+
+ createConfigMap(ns2, "cm1", null);
+ createConfigMap(ns2, "cm2", Map.of("otherKey", "otherValue"));
+ createConfigMap(ns1, "cm3", LABELS);
+ createConfigMap(ns2, "cm4", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-config-maps://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerNamespaceIT.java
new file mode 100644
index 00000000000..7510d854791
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerNamespaceIT.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.configmaps;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesConfigMapsConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() {
+ createConfigMap(ns1, "cm1", null);
+ createConfigMap(ns2, "cm2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, hasItem(containsString("cm2")));
+ assertThat(list, everyItem(not(containsString("cm1"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-config-maps://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerResourceNameIT.java
new file mode 100644
index 00000000000..0b6e3306880
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/configmaps/KubernetesConfigMapsConsumerResourceNameIT.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.configmaps;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesConfigMapsConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() throws Exception {
+ result.expectedBodiesReceived("ConfigMap " + WATCH_RESOURCE_NAME + " " + ns2 + " ADDED");
+
+ createConfigMap(ns1, WATCH_RESOURCE_NAME, null);
+ createConfigMap(ns2, WATCH_RESOURCE_NAME, null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-config-maps://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken,
+ WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideIT.java
new file mode 100644
index 00000000000..16b06971396
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideIT.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.deployments;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesDeploymentsConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createDeployment(ns1, "d1", null);
+ createDeployment(ns2, "d2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("d1")), hasItem(containsString("d2"))));
+ });
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-deployments://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..ae586751f26
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerClusterwideLabelsIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.deployments;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesDeploymentsConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() {
+ createDeployment(ns1, "d1", LABELS);
+ createDeployment(ns2, "d2", LABELS);
+ createDeployment(ns2, "d3", Map.of("otherKey", "otherValue"));
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ hasItem(containsString("d1")), hasItem(containsString("d2")), not(hasItem(containsString("d3")))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-deployments://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerLabelsIT.java
new file mode 100644
index 00000000000..a97335653bf
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerLabelsIT.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.deployments;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesDeploymentsConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() {
+ createDeployment(ns2, "d1", null);
+ createDeployment(ns2, "d2", Map.of("otherKey", "otherValue"));
+ createDeployment(ns1, "d3", LABELS);
+ createDeployment(ns2, "d4", LABELS);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ not(hasItem(containsString("d1"))),
+ not(hasItem(containsString("d2"))),
+ not(hasItem(containsString("d3"))),
+ hasItem(containsString("d4"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-deployments://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerNamespaceIT.java
new file mode 100644
index 00000000000..ed0b069e0f6
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerNamespaceIT.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.deployments;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesDeploymentsConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() {
+ createDeployment(ns1, "d1", null);
+ createDeployment(ns2, "d2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ hasItem(containsString("d2")),
+ not(hasItem(containsString("d1")))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-deployments://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerResourceNameIT.java
new file mode 100644
index 00000000000..7169cd6f2b7
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/deployments/KubernetesDeploymentsConsumerResourceNameIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.deployments;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesDeploymentsConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() {
+ createDeployment(ns1, WATCH_RESOURCE_NAME, null);
+ createDeployment(ns2, WATCH_RESOURCE_NAME, null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, everyItem(allOf(
+ containsString(WATCH_RESOURCE_NAME),
+ containsString(ns2),
+ not(containsString(ns1)))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-deployments://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken,
+ WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideIT.java
new file mode 100644
index 00000000000..c6f25a4c7d9
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideIT.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.events;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesEventsConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createEvent(ns1, "e1", null);
+ createEvent(ns2, "e2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("e1")), hasItem(containsString("e2"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-events://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..e32b930f838
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerClusterwideLabelsIT.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.events;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesEventsConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() throws Exception {
+ result.expectedBodiesReceivedInAnyOrder(
+ "Event e2 " + ns1 + " ADDED",
+ "Event e3 " + ns2 + " ADDED");
+ createEvent(ns2, "e1", Map.of("otherKey", "otherValue"));
+ createEvent(ns1, "e2", LABELS);
+ createEvent(ns2, "e3", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-events://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerLabelsIT.java
new file mode 100644
index 00000000000..6e24ab9dabe
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerLabelsIT.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.events;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesEventsConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() throws Exception {
+ result.expectedBodiesReceived("Event e4 " + ns2 + " ADDED");
+ createEvent(ns2, "e1", null);
+ createEvent(ns2, "e2", Map.of("otherKey", "otherValue"));
+ createEvent(ns1, "e3", LABELS);
+ createEvent(ns2, "e4", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-events://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerNamespaceIT.java
new file mode 100644
index 00000000000..edb59f32697
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerNamespaceIT.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.events;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesEventsConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() throws Exception {
+ result.expectedBodiesReceived("Event e2 " + ns2 + " ADDED");
+ createEvent(ns1, "e1", null);
+ createEvent(ns2, "e2", null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-events://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerResourceNameIT.java
new file mode 100644
index 00000000000..c6cac2e1682
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/events/KubernetesEventsConsumerResourceNameIT.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.events;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesEventsConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() throws Exception {
+ result.expectedBodiesReceived("Event " + WATCH_RESOURCE_NAME + " " + ns2 + " ADDED");
+
+ createEvent(ns1, WATCH_RESOURCE_NAME, null);
+ createEvent(ns2, WATCH_RESOURCE_NAME, null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-events://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken, WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideIT.java
new file mode 100644
index 00000000000..e4d2a8b8a6f
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideIT.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.hpa;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesHPAConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() throws Exception {
+ result.expectedBodiesReceivedInAnyOrder(
+ "HorizontalPodAutoscaler hpa1 " + ns1 + " ADDED",
+ "HorizontalPodAutoscaler hpa2 " + ns2 + " ADDED");
+
+ createHPA(ns1, "hpa1", null);
+ createHPA(ns2, "hpa2", null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-hpa://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..a14f0d85839
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerClusterwideLabelsIT.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.hpa;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesHPAConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() throws Exception {
+ result.expectedBodiesReceivedInAnyOrder(
+ "HorizontalPodAutoscaler hpa2 " + ns1 + " ADDED",
+ "HorizontalPodAutoscaler hpa3 " + ns2 + " ADDED");
+ createHPA(ns2, "hpa1", Map.of("otherKey", "otherValue"));
+ createHPA(ns1, "hpa2", LABELS);
+ createHPA(ns2, "hpa3", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-hpa://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerLabelsIT.java
new file mode 100644
index 00000000000..fc9aed14c28
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerLabelsIT.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.hpa;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesHPAConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() throws Exception {
+ result.expectedBodiesReceived("HorizontalPodAutoscaler hpa4 " + ns2 + " ADDED");
+ createHPA(ns2, "hpa1", null);
+ createHPA(ns2, "hpa2", Map.of("otherKey", "otherValue"));
+ createHPA(ns1, "hpa3", LABELS);
+ createHPA(ns2, "hpa4", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-hpa://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerNamespaceIT.java
new file mode 100644
index 00000000000..0e6af54ac87
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerNamespaceIT.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.hpa;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesHPAConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() throws Exception {
+ result.expectedBodiesReceived("HorizontalPodAutoscaler hpa2 " + ns2 + " ADDED");
+ createHPA(ns1, "hpa1", null);
+ createHPA(ns2, "hpa2", null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-hpa://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerResourceNameIT.java
new file mode 100644
index 00000000000..97c809addb5
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/hpa/KubernetesHPAConsumerResourceNameIT.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.hpa;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesHPAConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() throws Exception {
+ result.expectedBodiesReceived("HorizontalPodAutoscaler " + WATCH_RESOURCE_NAME + " " + ns2 + " ADDED");
+
+ createHPA(ns1, WATCH_RESOURCE_NAME, null);
+ createHPA(ns2, WATCH_RESOURCE_NAME, null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-hpa://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken, WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerClusterwideIT.java
new file mode 100644
index 00000000000..4d4e2ab5cc1
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerClusterwideIT.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.namespaces;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesNamespacesConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createNamespace("ns1", null);
+ createNamespace("ns2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("ns1")), hasItem(containsString("ns2"))));
+ });
+ }
+
+ @AfterEach
+ public void cleanup() {
+ List.of("ns1", "ns2").forEach(ns -> {
+ CLIENT.namespaces().withName(ns).delete();
+ Awaitility.await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> CLIENT.namespaces().withName(ns).get() == null);
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-namespaces://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerLabelsIT.java
new file mode 100644
index 00000000000..e49ba8eae88
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerLabelsIT.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.namespaces;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesNamespacesConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() throws Exception {
+ result.expectedBodiesReceived("Namespace ns3 ADDED");
+ createNamespace("ns1", null);
+ createNamespace("ns2", Map.of("otherKey", "otherValue"));
+ createNamespace("ns3", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @AfterEach
+ public void cleanup() {
+ List.of("ns1", "ns2", "ns3").forEach(ns -> {
+ CLIENT.namespaces().withName(ns).delete();
+ Awaitility.await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> CLIENT.namespaces().withName(ns).get() == null);
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-namespaces://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerResourceNameIT.java
new file mode 100644
index 00000000000..88483fb6606
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/namespaces/KubernetesNamespacesConsumerResourceNameIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.namespaces;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesNamespacesConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() throws Exception {
+ result.expectedBodiesReceived("Namespace " + WATCH_RESOURCE_NAME + " ADDED");
+
+ createNamespace(WATCH_RESOURCE_NAME, null);
+ createNamespace("ns1", null);
+
+ result.assertIsSatisfied();
+ }
+
+ @AfterEach
+ public void cleanup() {
+ List.of(WATCH_RESOURCE_NAME, "ns1").forEach(ns -> {
+ CLIENT.namespaces().withName(ns).delete();
+ Awaitility.await().atMost(10, TimeUnit.SECONDS)
+ .until(() -> CLIENT.namespaces().withName(ns).get() == null);
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-namespaces://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken,
+ WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideIT.java
new file mode 100644
index 00000000000..faf20006914
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideIT.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.pods;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesPodsConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createPod(ns1, "pod1", null);
+ createPod(ns2, "pod2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("pod1")), hasItem(containsString("pod2"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-pods://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..a0026c2563a
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerClusterwideLabelsIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.pods;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesPodsConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() {
+ createPod(ns2, "pod1", Map.of("otherKey", "otherValue"));
+ createPod(ns1, "pod2", LABELS);
+ createPod(ns2, "pod3", LABELS);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(not(hasItem(containsString("pod1"))), hasItem(containsString("pod2")),
+ hasItem(containsString("pod3"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-pods://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerLabelsIT.java
new file mode 100644
index 00000000000..ae349128bb1
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerLabelsIT.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.pods;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesPodsConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() {
+ createPod(ns2, "pod1", null);
+ createPod(ns2, "pod2", Map.of("otherKey", "otherValue"));
+ createPod(ns1, "pod3", LABELS);
+ createPod(ns2, "pod4", LABELS);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ not(hasItem(containsString("pod1"))),
+ not(hasItem(containsString("pod2"))),
+ not(hasItem(containsString("pod3"))),
+ hasItem(containsString("pod4"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-pods://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerNamespaceIT.java
new file mode 100644
index 00000000000..728489f6222
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerNamespaceIT.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.pods;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesPodsConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() {
+ createPod(ns1, "pod1", null);
+ createPod(ns2, "pod2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ not(hasItem(containsString("pod1"))),
+ hasItem(containsString("pod2"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-pods://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerResourceNameIT.java
new file mode 100644
index 00000000000..b144dc108c6
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/pods/KubernetesPodsConsumerResourceNameIT.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.pods;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesPodsConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() {
+ createPod(ns1, WATCH_RESOURCE_NAME, null);
+ createPod(ns2, WATCH_RESOURCE_NAME, null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, everyItem(allOf(
+ containsString(WATCH_RESOURCE_NAME),
+ containsString(ns2),
+ not(containsString(ns1)))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-pods://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken, WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideIT.java
new file mode 100644
index 00000000000..f006fbf410f
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideIT.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.replication_controllers;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesReplicationControllersConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createReplicationController(ns1, "rc1", null);
+ createReplicationController(ns2, "rc2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("rc1")), hasItem(containsString("rc2"))));
+ });
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-replication-controllers://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..df7aa899d75
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerClusterwideLabelsIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.replication_controllers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesReplicationControllersConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() {
+ createReplicationController(ns1, "rc1", LABELS);
+ createReplicationController(ns2, "rc2", LABELS);
+ createReplicationController(ns2, "rc3", Map.of("otherKey", "otherValue"));
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ hasItem(containsString("rc1")), hasItem(containsString("rc2")), not(hasItem(containsString("rc3")))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-replication-controllers://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerLabelsIT.java
new file mode 100644
index 00000000000..153b59800af
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerLabelsIT.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.replication_controllers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesReplicationControllersConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() {
+ createReplicationController(ns2, "rc1", null);
+ createReplicationController(ns2, "rc2", Map.of("otherKey", "otherValue"));
+ createReplicationController(ns1, "rc3", LABELS);
+ createReplicationController(ns2, "rc4", LABELS);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ not(hasItem(containsString("rc1"))),
+ not(hasItem(containsString("rc2"))),
+ not(hasItem(containsString("rc3"))),
+ hasItem(containsString("rc4"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-replication-controllers://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerNamespaceIT.java
new file mode 100644
index 00000000000..239b5848e96
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerNamespaceIT.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.replication_controllers;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesReplicationControllersConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() {
+ createReplicationController(ns1, "rc1", null);
+ createReplicationController(ns2, "rc2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(
+ hasItem(containsString("rc2")),
+ not(hasItem(containsString("rc1")))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-replication-controllers://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerResourceNameIT.java
new file mode 100644
index 00000000000..8fb6a64b3e5
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/replication_controllers/KubernetesReplicationControllersConsumerResourceNameIT.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.replication_controllers;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesReplicationControllersConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() {
+ createReplicationController(ns1, WATCH_RESOURCE_NAME, null);
+ createReplicationController(ns2, WATCH_RESOURCE_NAME, null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, everyItem(allOf(
+ containsString(WATCH_RESOURCE_NAME),
+ containsString(ns2),
+ not(containsString(ns1)))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-replication-controllers://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken,
+ WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideIT.java
new file mode 100644
index 00000000000..fa8ea3af8f5
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideIT.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.services;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.allOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesServicesConsumerClusterwideIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideTest() {
+ createService(ns1, "svc1", null);
+ createService(ns2, "svc2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, allOf(hasItem(containsString("svc1")), hasItem(containsString("svc2"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-services://%s?oauthToken=%s", host, authToken)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideLabelsIT.java
new file mode 100644
index 00000000000..d29a0101ed7
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerClusterwideLabelsIT.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.services;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesServicesConsumerClusterwideLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void clusterWideLabelsTest() throws Exception {
+ result.expectedBodiesReceivedInAnyOrder(
+ "Service svc1 " + ns1 + " ADDED",
+ "Service svc2 " + ns2 + " ADDED");
+
+ createService(ns1, "svc1", LABELS);
+ createService(ns2, "svc2", LABELS);
+ createService(ns2, "svc3", Map.of("otherKey", "otherValue"));
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-services://%s?oauthToken=%s&labelKey=%s&labelValue=%s",
+ host, authToken, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerLabelsIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerLabelsIT.java
new file mode 100644
index 00000000000..5e0e7a2889a
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerLabelsIT.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.services;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesServicesConsumerLabelsIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void labelsTest() throws Exception {
+ result.expectedBodiesReceived("Service svc4 " + ns2 + " ADDED");
+
+ createService(ns2, "svc1", null);
+ createService(ns2, "svc2", Map.of("otherKey", "otherValue"));
+ createService(ns1, "svc3", LABELS);
+ createService(ns2, "svc4", LABELS);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-services://%s?oauthToken=%s&namespace=%s&labelKey=%s&labelValue=%s",
+ host, authToken, ns2, "testkey", "testvalue")
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerNamespaceIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerNamespaceIT.java
new file mode 100644
index 00000000000..8e4a3460430
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerNamespaceIT.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.services;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesServicesConsumerNamespaceIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void namespaceTest() {
+ createService(ns1, "svc1", null);
+ createService(ns2, "svc2", null);
+
+ Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ final List<String> list = result.getExchanges().stream().map(ex -> ex.getIn().getBody(String.class)).toList();
+ assertThat(list, hasItem(containsString("svc2")));
+ assertThat(list, everyItem(not(containsString("svc1"))));
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-services://%s?oauthToken=%s&namespace=%s", host, authToken, ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerResourceNameIT.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerResourceNameIT.java
new file mode 100644
index 00000000000..1156610f18b
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/services/KubernetesServicesConsumerResourceNameIT.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.services;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.kubernetes.consumer.integration.support.KubernetesConsumerTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperties;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
+
+@EnabledIfSystemProperties({
+ @EnabledIfSystemProperty(named = "kubernetes.test.auth", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host", matches = ".*", disabledReason = "Requires kubernetes"),
+ @EnabledIfSystemProperty(named = "kubernetes.test.host.k8s", matches = "true", disabledReason = "Requires kubernetes"),
+})
+public class KubernetesServicesConsumerResourceNameIT extends KubernetesConsumerTestSupport {
+ @Test
+ public void resourceNameTest() throws Exception {
+ result.expectedBodiesReceived("Service " + WATCH_RESOURCE_NAME + " " + ns2 + " ADDED");
+
+ createService(ns1, WATCH_RESOURCE_NAME, null);
+ createService(ns2, WATCH_RESOURCE_NAME, null);
+
+ result.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ fromF("kubernetes-services://%s?oauthToken=%s&resourceName=%s&namespace=%s", host, authToken,
+ WATCH_RESOURCE_NAME,
+ ns2)
+ .process(new KubernetesProcessor())
+ .to(result);
+ }
+ };
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/support/KubernetesConsumerTestSupport.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/support/KubernetesConsumerTestSupport.java
new file mode 100644
index 00000000000..62df399c801
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/integration/support/KubernetesConsumerTestSupport.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.consumer.integration.support;
+
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+
+import io.fabric8.kubernetes.api.model.ConfigMap;
+import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.IntOrString;
+import io.fabric8.kubernetes.api.model.MicroTimeBuilder;
+import io.fabric8.kubernetes.api.model.Namespace;
+import io.fabric8.kubernetes.api.model.NamespaceBuilder;
+import io.fabric8.kubernetes.api.model.Pod;
+import io.fabric8.kubernetes.api.model.PodBuilder;
+import io.fabric8.kubernetes.api.model.ReplicationController;
+import io.fabric8.kubernetes.api.model.ReplicationControllerBuilder;
+import io.fabric8.kubernetes.api.model.Service;
+import io.fabric8.kubernetes.api.model.ServiceBuilder;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder;
+import io.fabric8.kubernetes.api.model.autoscaling.v1.HorizontalPodAutoscaler;
+import io.fabric8.kubernetes.api.model.autoscaling.v1.HorizontalPodAutoscalerBuilder;
+import io.fabric8.kubernetes.api.model.events.v1.Event;
+import io.fabric8.kubernetes.api.model.events.v1.EventBuilder;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.kubernetes.client.KubernetesClientBuilder;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.component.kubernetes.KubernetesTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class KubernetesConsumerTestSupport extends KubernetesTestSupport {
+ protected static final KubernetesClient CLIENT = new KubernetesClientBuilder().build();
+
+ protected static String ns1;
+ protected static String ns2;
+
+ protected static final Map<String, String> LABELS = Map.of("testkey", "testvalue");
+ protected static final String WATCH_RESOURCE_NAME = "watch-resource";
+
+ @EndpointInject("mock:result")
+ protected MockEndpoint result;
+
+ @BeforeAll
+ public static void createNamespaces() {
+ ns1 = "kubernetesitcase-" + ThreadLocalRandom.current().nextInt(0, 100000);
+ ns2 = "kubernetesitcase-" + ThreadLocalRandom.current().nextInt(0, 100000);
+ CLIENT.namespaces().resource(new NamespaceBuilder().withNewMetadata().withName(ns1).endMetadata().build())
+ .serverSideApply();
+ CLIENT.namespaces().resource(new NamespaceBuilder().withNewMetadata().withName(ns2).endMetadata().build())
+ .serverSideApply();
+ }
+
+ @AfterAll
+ public static void deleteNamespaces() {
+ CLIENT.namespaces().withName(ns1).delete();
+ CLIENT.namespaces().withName(ns2).delete();
+ }
+
+ @AfterEach
+ public void cleanup() {
+ result.reset();
+ }
+
+ protected void createConfigMap(String namespace, String name, Map<String, String> labels) {
+ Map<String, String> data = Map.of("test1", "test1");
+
+ ConfigMap cm = new ConfigMapBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withData(data)
+ .build();
+
+ CLIENT.configMaps().inNamespace(namespace).resource(cm).serverSideApply();
+ assertNotNull(CLIENT.configMaps().inNamespace(namespace).withName(name).get());
+ }
+
+ protected void createDeployment(String namespace, String name, Map<String, String> labels) {
+ Deployment deployment = new DeploymentBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withNewSpec()
+ .withReplicas(0)
+ .withNewSelector()
+ .addToMatchLabels("app", "test")
+ .endSelector()
+ .withNewTemplate()
+ .withNewMetadata()
+ .addToLabels("app", "test")
+ .endMetadata()
+ .withNewSpec()
+ .addNewContainer()
+ .withName("test")
+ // Does not matter, we don't start the deployment (replicas == 0)
+ .withImage("test:1.0")
+ .endContainer()
+ .endSpec()
+ .endTemplate()
+ .endSpec()
+ .build();
+
+ CLIENT.apps().deployments().inNamespace(namespace).resource(deployment).serverSideApply();
+ assertNotNull(CLIENT.apps().deployments().inNamespace(namespace).withName(name).get());
+ }
+
+ protected void createEvent(String namespace, String name, Map<String, String> labels) {
+ Event event = new EventBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withReason("Reason")
+ .withType("Normal")
+ .withEventTime(new MicroTimeBuilder().withTime("2025-01-01T00:00:00.000000Z").build())
+ .withNewRegarding()
+ .withKind("Pod")
+ .withName("test")
+ .withNamespace(namespace)
+ .endRegarding()
+ .withReportingController("ReportingController")
+ .withReportingInstance("ReportingInstance")
+ .withAction("Action")
+ .build();
+
+ CLIENT.events().v1().events().inNamespace(namespace).resource(event).serverSideApply();
+ assertNotNull(CLIENT.events().v1().events().inNamespace(namespace).withName(name).get());
+ }
+
+ protected void createHPA(String namespace, String name, Map<String, String> labels) {
+ HorizontalPodAutoscaler hpa = new HorizontalPodAutoscalerBuilder()
+ .withNewMetadata().withName(name).withLabels(labels)
+ .endMetadata()
+ .withNewSpec()
+ .withMinReplicas(1)
+ .withMaxReplicas(5)
+ .withTargetCPUUtilizationPercentage(50)
+ .withNewScaleTargetRef()
+ .withApiVersion("apps/v1")
+ .withKind("Deployment")
+ .withName("test")
+ .endScaleTargetRef()
+ .endSpec()
+ .build();
+
+ CLIENT.autoscaling().v1().horizontalPodAutoscalers().inNamespace(namespace).resource(hpa).serverSideApply();
+ assertNotNull(CLIENT.autoscaling().v1().horizontalPodAutoscalers().inNamespace(namespace).withName(name).get());
+ }
+
+ protected void createNamespace(String name, Map<String, String> labels) {
+ Namespace namespace = new NamespaceBuilder()
+ .withNewMetadata().withName(name).withLabels(labels)
+ .endMetadata()
+ .build();
+
+ CLIENT.namespaces().resource(namespace).serverSideApply();
+ assertNotNull(CLIENT.namespaces().withName(name).get());
+ }
+
+ protected void createPod(String namespace, String name, Map<String, String> labels) {
+ Pod pod = new PodBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withNewSpec()
+ .withRestartPolicy("Never")
+ .addNewContainer()
+ .withName(name)
+ .withImage("busybox")
+ .endContainer()
+ .endSpec()
+ .build();
+
+ CLIENT.pods().inNamespace(namespace).resource(pod).serverSideApply();
+ assertNotNull(CLIENT.pods().inNamespace(namespace).withName(name).get());
+ // Also wait until the pod completes, otherwise it may prevent ns from being deleted if deleted too quickly
+ Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> {
+ Pod p = CLIENT.pods().inNamespace(namespace).withName(name).get();
+ return p.getStatus() != null && "Succeeded".equals(p.getStatus().getPhase());
+ });
+ }
+
+ protected void createReplicationController(String namespace, String name, Map<String, String> labels) {
+ ReplicationController rc = new ReplicationControllerBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withNewSpec()
+ .withReplicas(0)
+ .withSelector(Map.of("key", "value"))
+ .withNewTemplate()
+ .withNewMetadata()
+ .withLabels(Map.of("key", "value"))
+ .endMetadata()
+ .withNewSpec()
+ .addNewContainer()
+ .withName(name)
+ .withImage("busybox")
+ .endContainer()
+ .endSpec()
+ .endTemplate()
+ .endSpec()
+ .build();
+ CLIENT.replicationControllers().inNamespace(namespace).resource(rc).serverSideApply();
+ assertNotNull(CLIENT.replicationControllers().inNamespace(namespace).withName(name).get());
+ }
+
+ protected void createService(String namespace, String name, Map<String, String> labels) {
+ Service svc = new ServiceBuilder()
+ .withNewMetadata().withName(name).withLabels(labels).endMetadata()
+ .withNewSpec()
+ .addNewPort()
+ .withProtocol("TCP")
+ .withPort(80)
+ .withTargetPort(new IntOrString(8080))
+ .endPort()
+ .withSelector(Map.of("test", "test"))
+ .withType("ClusterIP")
+ .endSpec()
+ .build();
+
+ CLIENT.services().inNamespace(namespace).resource(svc).serverSideApply();
+ assertNotNull(CLIENT.services().inNamespace(namespace).withName(name).get());
+ }
+
+ public static class KubernetesProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) {
+ final Message in = exchange.getIn();
+ HasMetadata res = in.getBody(HasMetadata.class);
+ StringBuilder body = new StringBuilder(res.getKind()).append(" ").append(res.getMetadata().getName());
+ String ns = res.getMetadata().getNamespace();
+ if (ns != null) {
+ body.append(" ").append(ns);
+ }
+ body.append(" ").append(in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+ exchange.getIn().setBody(body.toString());
+ }
+ }
+}
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
index a7278043cbc..754be2d22fb 100644
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.camel.component.kubernetes.producer;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
@@ -54,25 +54,44 @@ public class KubernetesConfigMapsProducerTest extends KubernetesTestSupport {
server.expect().withPath("/api/v1/configmaps")
.andReturn(200, new ConfigMapListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build())
.once();
+ server.expect().withPath("/api/v1/namespaces/test/configmaps")
+ .andReturn(200, new ConfigMapListBuilder().addNewItem().and().addNewItem().and().build())
+ .once();
List<?> result = template.requestBody("direct:list", "", List.class);
assertEquals(3, result.size());
+
+ Exchange ex = template.request("direct:list",
+ exchange -> exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test"));
+ assertEquals(2, ex.getMessage().getBody(List.class).size());
}
@Test
void listByLabelsTest() throws Exception {
- server.expect().withPath("/api/v1/configmaps?labelSelector=" + toUrlEncoded("key1=value1,key2=value2"))
+ Map<String, String> labels = Map.of(
+ "key1", "value1",
+ "key2", "value2");
+
+ String urlEncodedLabels = toUrlEncoded(labels.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
+ .collect(Collectors.joining(",")));
+
+ server.expect().withPath("/api/v1/configmaps?labelSelector=" + urlEncodedLabels)
.andReturn(200, new ConfigMapListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build())
.once();
+ server.expect().withPath("/api/v1/namespaces/test/configmaps?labelSelector=" + urlEncodedLabels)
+ .andReturn(200, new ConfigMapListBuilder().addNewItem().and().addNewItem().and().build())
+ .once();
Exchange ex = template.request("direct:listConfigMapsByLabels", exchange -> {
- Map<String, String> labels = new HashMap<>();
- labels.put("key1", "value1");
- labels.put("key2", "value2");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, labels);
});
- List<?> result = ex.getMessage().getBody(List.class);
+ assertEquals(3, ex.getMessage().getBody(List.class).size());
- assertEquals(3, result.size());
+ ex = template.request("direct:listConfigMapsByLabels", exchange -> {
+ exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, labels);
+ exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test");
+ });
+
+ assertEquals(2, ex.getMessage().getBody(List.class).size());
}
@Test
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java
index f9f1ba9f7e5..559060cba60 100644
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesResourcesQuotaProducerTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.kubernetes.producer;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import io.fabric8.kubernetes.api.model.ResourceQuota;
import io.fabric8.kubernetes.api.model.ResourceQuotaBuilder;
@@ -59,6 +60,28 @@ public class KubernetesResourcesQuotaProducerTest extends KubernetesTestSupport
assertEquals(3, result.size());
}
+ @Test
+ public void listByLabelsTest() throws Exception {
+ Map<String, String> labels = Map.of(
+ "key1", "value1",
+ "key2", "value2");
+
+ String urlEncodedLabels = toUrlEncoded(labels.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
+ .collect(Collectors.joining(",")));
+
+ server.expect().withPath("/api/v1/resourcequotas?labelSelector=" + urlEncodedLabels)
+ .andReturn(200,
+ new ResourceQuotaListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build())
+ .once();
+ Exchange ex = template.request("direct:listByLabels", exchange -> {
+ exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_LABELS, labels);
+ });
+
+ List<?> result = ex.getMessage().getBody(List.class);
+
+ assertEquals(3, result.size());
+ }
+
@Test
void createResourceQuota() {
Map<String, String> labels = Map.of("my.label.key", "my.label.value");
@@ -132,6 +155,8 @@ public class KubernetesResourcesQuotaProducerTest extends KubernetesTestSupport
public void configure() {
from("direct:list")
.to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=listResourcesQuota");
+ from("direct:listByLabels")
+ .to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=listResourcesQuotaByLabels");
from("direct:create")
.to("kubernetes-resources-quota:///?kubernetesClient=#kubernetesClient&operation=createResourceQuota");
from("direct:update")
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java
index 6cb72696199..db2bdbd43f2 100644
--- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesServiceAccountsProducerTest.java
@@ -125,6 +125,24 @@ public class KubernetesServiceAccountsProducerTest extends KubernetesTestSupport
assertTrue(secDeleted);
}
+ @Test
+ public void getServiceAccount() {
+ final String name = "sa1";
+ final String ns = "test";
+ ServiceAccount sa = new ServiceAccountBuilder().withNewMetadata().withName(name).withNamespace(ns).and().build();
+ server.expect().get().withPath("/api/v1/namespaces/" + ns + "/serviceaccounts/" + name).andReturn(200, sa).once();
+
+ Exchange ex = template.request("direct:get", exchange -> {
+ exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, ns);
+ exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNT_NAME, name);
+ });
+
+ ServiceAccount result = ex.getMessage().getBody(ServiceAccount.class);
+
+ assertEquals(ns, result.getMetadata().getNamespace());
+ assertEquals(name, result.getMetadata().getName());
+ }
+
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@@ -140,6 +158,8 @@ public class KubernetesServiceAccountsProducerTest extends KubernetesTestSupport
"kubernetes-service-accounts:///?kubernetesClient=#kubernetesClient&operation=updateServiceAccount");
from("direct:delete").to(
"kubernetes-service-accounts:///?kubernetesClient=#kubernetesClient&operation=deleteServiceAccount");
+ from("direct:get")
+ .to("kubernetes-service-accounts:///?kubernetesClient=#kubernetesClient&operation=getServiceAccount");
}
};
}