Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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");
--------------------------------------------------------------------------------

Expand All @@ -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");
--------------------------------------------------------------------------------

Expand All @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Loading