This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit e1a6b9ac4d0ff96e2fd1341cf4c740c6d4d869d0 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon Sep 23 10:03:11 2019 +0200 Camel-Kubernetes: Added samples code for namespaces component --- .../main/docs/kubernetes-namespaces-component.adoc | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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 9a0b61b..f4c21f3 100644 --- a/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc +++ b/components/camel-kubernetes/src/main/docs/kubernetes-namespaces-component.adoc @@ -119,3 +119,55 @@ The component supports 2 options, which are listed below. - createNamespace - deleteNamespace +== Kubernetes Namespaces Producer Examples + +- listNamespaces: this operation list the namespaces on a kubernetes cluster + +[source,java] +-------------------------------------------------------------------------------- +from("direct:list"). + toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listNamespaces"). + to("mock:result"); +-------------------------------------------------------------------------------- + +This operation return a List of namespaces from your cluster + +- listNamespacesByLabels: this operation list the namespaces by labels on a kubernetes cluster + +[source,java] +-------------------------------------------------------------------------------- +from("direct:listByLabels").process(new Processor() { + + @Override + public void process(Exchange exchange) throws Exception { + Map<String, String> labels = new HashMap<>(); + labels.put("key1", "value1"); + labels.put("key2", "value2"); + exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACES_LABELS, labels); + } + }); + toF("kubernetes-deployments:///?kubernetesClient=#kubernetesClient&operation=listNamespacesByLabels"). + to("mock:result"); +-------------------------------------------------------------------------------- + +This operation return a List of Namespaces from your cluster, using a label selector (with key1 and key2, with value value1 and value2) + +== Kubernetes Namespaces Consumer Example + +[source,java] +-------------------------------------------------------------------------------- +fromF("kubernetes-namespaces://%s?oauthToken=%s&namespace=default", host, authToken).process(new KubernertesProcessor()).to("mock:result"); + + public class KubernertesProcessor 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)); + } + } +-------------------------------------------------------------------------------- + +This consumer will return a list of events on the namespace default. + +