camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [4/7] camel git commit: CAMEL-9085 Create a Camel-Kubernetes/Openshift v3 Component
Date Sun, 18 Oct 2015 08:18:56 GMT
http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/main/resources/META-INF/LICENSE.txt b/components/camel-kubernetes/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-kubernetes/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/main/resources/META-INF/NOTICE.txt b/components/camel-kubernetes/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-kubernetes/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/component/kubernetes
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/component/kubernetes b/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/component/kubernetes
new file mode 100644
index 0000000..4d2f23e
--- /dev/null
+++ b/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/component/kubernetes
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.kubernetes.KubernetesComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/KubernetesTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/KubernetesTestSupport.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/KubernetesTestSupport.java
new file mode 100644
index 0000000..79ed5e8
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/KubernetesTestSupport.java
@@ -0,0 +1,38 @@
+/**
+ * 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;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+public class KubernetesTestSupport extends CamelTestSupport{
+
+    protected String authToken;
+    protected String host;
+
+    // The Camel-Kubernetes tests are based on vagrant fabric8-image
+    // https://github.com/fabric8io/fabric8-installer/tree/master/vagrant/openshift
+    // by running the vagrant image you'll have an environment with
+    // Openshift/Kubernetes installed
+
+    @Override
+    public void setUp() throws Exception {
+        // INSERT credentials and host here
+        authToken = "";
+        host = "https://172.28.128.4:8443";
+        super.setUp();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesPodsConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesPodsConsumerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesPodsConsumerTest.java
new file mode 100644
index 0000000..08d1929
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesPodsConsumerTest.java
@@ -0,0 +1,158 @@
+/**
+ * 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;
+
+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 io.fabric8.kubernetes.client.Config;
+import io.fabric8.kubernetes.client.ConfigBuilder;
+import io.fabric8.kubernetes.client.DefaultKubernetesClient;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+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.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesPodsConsumerTest extends KubernetesTestSupport {
+    
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+
+
+    @Test
+    public void createAndDeletePod() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        
+        mockResultEndpoint.expectedMessageCount(3);
+        mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED", "MODIFIED", "DELETED");
+        Exchange ex = template.request("direct:createPod", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_NAME, "test");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_PODS_LABELS, labels);
+                PodSpec podSpec = new PodSpec();
+                podSpec.setHost("172.28.128.4");
+                Container cont = new Container();
+                cont.setImage("docker.io/jboss/wildfly:latest");
+                cont.setName("pippo");
+
+                List<ContainerPort> containerPort = new ArrayList<ContainerPort>();
+                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<Container>();
+                list.add(cont);
+
+                podSpec.setContainers(list);
+
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_SPEC, podSpec);
+            }
+        });
+
+        Pod pod = ex.getOut().getBody(Pod.class);
+
+        assertEquals(pod.getMetadata().getName(), "test");
+
+        ex = template.request("direct:deletePod", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_NAME, "test");
+            }
+        });
+
+        boolean podDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(podDeleted);
+        
+        Thread.sleep(1*1000);
+
+        mockResultEndpoint.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=listPods",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=listPodsByLabels",
+                                host, authToken);
+                from("direct:getPod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=getPod",
+                                host, authToken);
+                from("direct:createPod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=createPod",
+                                host, authToken);
+                from("direct:deletePod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=deletePod",
+                                host, authToken);
+                fromF("kubernetes://%s?oauthToken=%s&category=pods", host, authToken)
+                        .process(new KubernertesProcessor())
+                        .to(mockResultEndpoint);
+            }
+        };
+    }
+    
+    public class KubernertesProcessor implements Processor {
+        @Override
+        public void process(Exchange exchange) throws Exception {
+            Message in = exchange.getIn();
+            log.info("Got event with body: " + in.getBody() + " and action " + in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesReplicationControllersConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesReplicationControllersConsumerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesReplicationControllersConsumerTest.java
new file mode 100644
index 0000000..e9df6dc
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesReplicationControllersConsumerTest.java
@@ -0,0 +1,165 @@
+/**
+ * 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;
+
+import io.fabric8.kubernetes.api.model.EditablePodTemplateSpec;
+import io.fabric8.kubernetes.api.model.IntOrString;
+import io.fabric8.kubernetes.api.model.PodTemplateSpecBuilder;
+import io.fabric8.kubernetes.api.model.ReplicationController;
+import io.fabric8.kubernetes.api.model.ReplicationControllerSpec;
+import io.fabric8.kubernetes.api.model.Service;
+import io.fabric8.kubernetes.api.model.ServicePort;
+import io.fabric8.kubernetes.api.model.ServiceSpec;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesReplicationControllersConsumerTest extends
+		KubernetesTestSupport {
+
+	@EndpointInject(uri = "mock:result")
+	protected MockEndpoint mockResultEndpoint;
+
+	@Test
+	public void createAndDeleteReplicationController() throws Exception {
+		if (ObjectHelper.isEmpty(authToken)) {
+			return;
+		}
+
+		mockResultEndpoint
+				.expectedHeaderValuesReceivedInAnyOrder(
+						KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
+						"DELETED", "MODIFIED", "MODIFIED", "MODIFIED");
+        Exchange ex = template.request("direct:createReplicationController",
+                new Processor() {
+
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getIn().setHeader(
+                                KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                                "default");
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME,
+                                        "test");
+                        Map<String, String> labels = new HashMap<String, String>();
+                        labels.put("this", "rocks");
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS,
+                                        labels);
+                        ReplicationControllerSpec rcSpec = new ReplicationControllerSpec();
+                        rcSpec.setReplicas(2);
+                        PodTemplateSpecBuilder builder = new PodTemplateSpecBuilder();
+                        EditablePodTemplateSpec 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<String, String>();
+                        selectorMap.put("server", "nginx");
+                        rcSpec.setSelector(selectorMap);
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_SPEC,
+                                        rcSpec);
+                    }
+                });
+
+        ReplicationController rc = ex.getOut().getBody(
+                ReplicationController.class);
+
+        assertEquals(rc.getMetadata().getName(), "test");
+
+        ex = template.request("direct:deleteReplicationController",
+                new Processor() {
+
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getIn().setHeader(
+                                KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                                "default");
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME,
+                                        "test");
+                    }
+                });
+
+        boolean rcDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(rcDeleted);
+
+		Thread.sleep(1 * 1000);
+
+		mockResultEndpoint.assertIsSatisfied();
+	}
+
+	@Override
+	protected RouteBuilder createRouteBuilder() throws Exception {
+		return new RouteBuilder() {
+			@Override
+			public void configure() throws Exception {
+				from("direct:list")
+						.toF("kubernetes://%s?oauthToken=%s&category=replicationControllers&operation=listReplicationControllers",
+								host, authToken);
+				from("direct:listByLabels")
+						.toF("kubernetes://%s?oauthToken=%s&category=replicationControllers&operation=listReplicationControllersByLabels",
+								host, authToken);
+				from("direct:getReplicationController")
+						.toF("kubernetes://%s?oauthToken=%s&category=replicationControllers&operation=getReplicationController",
+								host, authToken);
+				from("direct:createReplicationController")
+						.toF("kubernetes://%s?oauthToken=%s&category=replicationControllers&operation=createReplicationController",
+								host, authToken);
+				from("direct:deleteReplicationController")
+						.toF("kubernetes://%s?oauthToken=%s&category=replicationControllers&operation=deleteReplicationController",
+								host, authToken);
+				fromF(
+						"kubernetes://%s?oauthToken=%s&category=replicationControllers",
+						host, authToken).process(new KubernertesProcessor())
+						.to(mockResultEndpoint);
+			}
+		};
+	}
+
+	public class KubernertesProcessor implements Processor {
+		@Override
+		public void process(Exchange exchange) throws Exception {
+			Message in = exchange.getIn();
+			log.info("Got event with body: " + in.getBody() + " and action "
+					+ in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesSecretsConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesSecretsConsumerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesSecretsConsumerTest.java
new file mode 100644
index 0000000..e19ce67
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesSecretsConsumerTest.java
@@ -0,0 +1,141 @@
+/**
+ * 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;
+
+import io.fabric8.kubernetes.api.model.ObjectMeta;
+import io.fabric8.kubernetes.api.model.Secret;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+import com.ning.http.util.Base64;
+
+public class KubernetesSecretsConsumerTest extends KubernetesTestSupport {
+
+	@EndpointInject(uri = "mock:result")
+	protected MockEndpoint mockResultEndpoint;
+
+	@Test
+	public void createAndDeleteSecrets() throws Exception {
+		if (ObjectHelper.isEmpty(authToken)) {
+			return;
+		}
+
+		mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(
+				KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED",
+				"DELETED");
+		Exchange ex = template.request("direct:create", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_SECRET_NAME, "test");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_SECRETS_LABELS, labels);
+                Secret s = new Secret();
+                s.setKind("Secret");
+                Map<String, String> mp = new HashMap<String, String>();
+                mp.put("username", Base64.encode("pippo".getBytes()));
+                mp.put("password", Base64.encode("password".getBytes()));
+                s.setData(mp);
+
+                ObjectMeta meta = new ObjectMeta();
+                meta.setName("test");
+                s.setMetadata(meta);
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_SECRET, s);
+            }
+        });
+
+        Secret sec = ex.getOut().getBody(Secret.class);
+
+        assertEquals(sec.getMetadata().getName(), "test");
+
+        ex = template.request("direct:delete", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_SECRET_NAME, "test");
+            }
+        });
+
+        boolean secDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(secDeleted);
+
+		Thread.sleep(1 * 1000);
+
+		mockResultEndpoint.assertIsSatisfied();
+	}
+
+	@Override
+	protected RouteBuilder createRouteBuilder() throws Exception {
+		return new RouteBuilder() {
+			@Override
+			public void configure() throws Exception {
+				from("direct:list")
+						.toF("kubernetes://%s?oauthToken=%s&category=secrets&operation=listSecrets",
+								host, authToken);
+				from("direct:listByLabels")
+						.toF("kubernetes://%s?oauthToken=%s&category=secrets&operation=listSecretsByLabels",
+								host, authToken);
+				from("direct:get")
+						.toF("kubernetes://%s?oauthToken=%s&category=secrets&operation=getSecret",
+								host, authToken);
+				from("direct:create")
+						.toF("kubernetes://%s?oauthToken=%s&category=secrets&operation=createSecret",
+								host, authToken);
+				from("direct:delete")
+						.toF("kubernetes://%s?oauthToken=%s&category=secrets&operation=deleteSecret",
+								host, authToken);
+				fromF("kubernetes://%s?oauthToken=%s&category=secrets", host,
+						authToken).process(new KubernertesProcessor()).to(
+						mockResultEndpoint);
+			}
+		};
+	}
+
+	public class KubernertesProcessor implements Processor {
+		@Override
+		public void process(Exchange exchange) throws Exception {
+			Message in = exchange.getIn();
+			log.info("Got event with body: " + in.getBody() + " and action "
+					+ in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesServicesConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesServicesConsumerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesServicesConsumerTest.java
new file mode 100644
index 0000000..098069e
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/consumer/KubernetesServicesConsumerTest.java
@@ -0,0 +1,145 @@
+/**
+ * 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;
+
+import io.fabric8.kubernetes.api.model.IntOrString;
+import io.fabric8.kubernetes.api.model.Service;
+import io.fabric8.kubernetes.api.model.ServicePort;
+import io.fabric8.kubernetes.api.model.ServiceSpec;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesServicesConsumerTest extends KubernetesTestSupport {
+	
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint mockResultEndpoint;
+
+	@Test
+	public void createAndDeleteService() throws Exception {
+		if (ObjectHelper.isEmpty(authToken)) {
+			return;
+		}
+		
+        mockResultEndpoint.expectedMessageCount(2);
+        mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "ADDED", "DELETED");
+		Exchange ex = template.request("direct:createService", new Processor() {
+
+			@Override
+			public void process(Exchange exchange) throws Exception {
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+						"default");
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_SERVICE_NAME, "test");
+				Map<String, String> labels = new HashMap<String, String>();
+				labels.put("this", "rocks");
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_SERVICE_LABELS, labels);
+				ServiceSpec serviceSpec = new ServiceSpec();
+				List<ServicePort> lsp = new ArrayList<ServicePort>();
+				ServicePort sp = new ServicePort();
+				sp.setPort(8080);
+				sp.setTargetPort(new IntOrString(8080));
+				sp.setProtocol("TCP");
+				lsp.add(sp);
+				serviceSpec.setPorts(lsp);
+				Map<String, String> selectorMap = new HashMap<String, String>();
+				selectorMap.put("containter", "test");
+				serviceSpec.setSelector(selectorMap);
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_SERVICE_SPEC,
+						serviceSpec);
+			}
+		});
+
+		Service serv = ex.getOut().getBody(Service.class);
+
+		assertEquals(serv.getMetadata().getName(), "test");
+
+		ex = template.request("direct:deleteService", new Processor() {
+
+			@Override
+			public void process(Exchange exchange) throws Exception {
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+						"default");
+				exchange.getIn().setHeader(
+						KubernetesConstants.KUBERNETES_SERVICE_NAME, "test");
+			}
+		});
+
+		boolean servDeleted = ex.getOut().getBody(Boolean.class);
+
+		assertTrue(servDeleted);
+		
+        Thread.sleep(1*1000);
+
+        mockResultEndpoint.assertIsSatisfied();
+	}
+
+	@Override
+	protected RouteBuilder createRouteBuilder() throws Exception {
+		return new RouteBuilder() {
+			@Override
+			public void configure() throws Exception {
+				from("direct:list")
+						.toF("kubernetes://%s?oauthToken=%s&category=services&operation=listServices",
+								host, authToken);
+				from("direct:listByLabels")
+						.toF("kubernetes://%s?oauthToken=%s&category=services&operation=listServicesByLabels",
+								host, authToken);
+				from("direct:getServices")
+						.toF("kubernetes://%s?oauthToken=%s&category=services&operation=getService",
+								host, authToken);
+				from("direct:createService")
+						.toF("kubernetes://%s?oauthToken=%s&category=services&operation=createService",
+								host, authToken);
+                from("direct:deleteService")
+                        .toF("kubernetes://%s?oauthToken=%s&category=services&operation=deleteService",
+                        host, authToken);
+				fromF("kubernetes://%s?oauthToken=%s&category=services",
+						host, authToken)
+						.process(new KubernertesProcessor())
+						.to(mockResultEndpoint);
+			}
+		};
+	}
+
+	public class KubernertesProcessor implements Processor {
+		@Override
+		public void process(Exchange exchange) throws Exception {
+			Message in = exchange.getIn();
+			log.info("Got event with body: " + in.getBody() + " and action "
+					+ in.getHeader(KubernetesConstants.KUBERNETES_EVENT_ACTION));
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildConfigsProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildConfigsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildConfigsProducerTest.java
new file mode 100644
index 0000000..ab0e907
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildConfigsProducerTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.producer;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.openshift.api.model.BuildConfig;
+
+import org.apache.camel.Exchange;
+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.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesBuildConfigsProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<BuildConfig> result = template.requestBody("direct:list", "",
+                List.class);
+
+        assertTrue(result.size() == 0);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("component", "elasticsearch");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_BUILD_CONFIGS_LABELS,
+                                labels);
+            }
+        });
+
+        List<BuildConfig> result = ex.getOut().getBody(List.class);
+        
+        assertTrue(result.size() == 0);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=buildConfigs&operation=listBuildConfigs",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=buildConfigs&operation=listBuildConfigsByLabels",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildsProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildsProducerTest.java
new file mode 100644
index 0000000..5e68906
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesBuildsProducerTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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.producer;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.kubernetes.api.model.PersistentVolume;
+import io.fabric8.openshift.api.model.Build;
+
+import org.apache.camel.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class KubernetesBuildsProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<Build> result = template.requestBody("direct:list", "",
+                List.class);
+
+        assertTrue(result.size() == 0);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("component", "elasticsearch");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_BUILDS_LABELS,
+                                labels);
+            }
+        });
+
+        List<Build> result = ex.getOut().getBody(List.class);
+        
+        assertTrue(result.size() == 0);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=builds&operation=listBuilds",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=builds&operation=listBuildsByLabels",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java
new file mode 100644
index 0000000..21e84d1
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNamespacesProducerTest.java
@@ -0,0 +1,210 @@
+/**
+ * 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.producer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.kubernetes.api.model.Namespace;
+
+import org.apache.camel.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesNamespacesProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<Namespace> result = template.requestBody("direct:list", "",
+                List.class);
+
+        boolean defaultExists = false;
+
+        Iterator<Namespace> it = result.iterator();
+        while (it.hasNext()) {
+            Namespace namespace = (Namespace) it.next();
+            if ("default".equalsIgnoreCase(namespace.getMetadata().getName())) {
+                defaultExists = true;
+            }
+        }
+
+        assertTrue(defaultExists);
+    }
+
+    @Test
+    public void getNamespace() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:getNs", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+            }
+        });
+
+        Namespace ns = ex.getOut().getBody(Namespace.class);
+
+        assertEquals(ns.getMetadata().getName(), "default");
+
+    }
+
+    @Test
+    public void createAndDeleteNamespace() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:createNamespace",
+                new Processor() {
+
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getIn().setHeader(
+                                KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                                "test");
+                        Map<String, String> labels = new HashMap<String, String>();
+                        labels.put("this", "rocks");
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_NAMESPACE_LABELS,
+                                        labels);
+                    }
+                });
+
+        Namespace ns = ex.getOut().getBody(Namespace.class);
+
+        assertEquals(ns.getMetadata().getName(), "test");
+
+        
+        ex = template.request("direct:deleteNamespace", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test");
+            }
+        });
+
+        boolean nsDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(nsDeleted);
+    }
+
+    @Test
+    public void createListByLabelsAndDeleteNamespace() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:createNamespace",
+                new Processor() {
+
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        exchange.getIn().setHeader(
+                                KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                                "test");
+                        Map<String, String> labels = new HashMap<String, String>();
+                        labels.put("this", "rocks");
+                        exchange.getIn()
+                                .setHeader(
+                                        KubernetesConstants.KUBERNETES_NAMESPACE_LABELS,
+                                        labels);
+                    }
+                });
+
+        Namespace ns = ex.getOut().getBody(Namespace.class);
+
+        assertEquals(ns.getMetadata().getName(), "test");
+
+        ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_NAMESPACE_LABELS,
+                                labels);
+            }
+        });
+
+        List<Namespace> result = ex.getOut().getBody(List.class);
+
+        boolean testExists = false;
+
+        Iterator<Namespace> it = result.iterator();
+        while (it.hasNext()) {
+            Namespace namespace = (Namespace) it.next();
+            if ("test".equalsIgnoreCase(namespace.getMetadata().getName())) {
+                testExists = true;
+            }
+        }
+
+        assertTrue(testExists);
+
+        ex = template.request("direct:deleteNamespace", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "test");
+            }
+        });
+
+        boolean nsDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(nsDeleted);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=namespaces&operation=listNamespaces",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=namespaces&operation=listNamespacesByLabels",
+                                host, authToken);
+                from("direct:getNs")
+                        .toF("kubernetes://%s?oauthToken=%s&category=namespaces&operation=getNamespace",
+                                host, authToken);
+                from("direct:createNamespace")
+                        .toF("kubernetes://%s?oauthToken=%s&category=namespaces&operation=createNamespace",
+                                host, authToken);
+                from("direct:deleteNamespace")
+                        .toF("kubernetes://%s?oauthToken=%s&category=namespaces&operation=deleteNamespace",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java
new file mode 100644
index 0000000..6d12321
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesNodesProducerTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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.producer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.kubernetes.api.model.Node;
+import io.fabric8.kubernetes.api.model.PersistentVolume;
+
+import org.apache.camel.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class KubernetesNodesProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<Node> result = template.requestBody("direct:list", "",
+                List.class);
+
+        assertTrue(result.size() == 1);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("kubernetes.io/hostname", "172.28.128.4");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_NODES_LABELS,
+                                labels);
+            }
+        });
+
+        List<Node> result = ex.getOut().getBody(List.class);
+        
+        Node node = result.get(0);
+        
+        assertTrue(node.getStatus().getCapacity().get("pods").getAmount().equals("40"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=nodes&operation=listNodes",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=nodes&operation=listNodesByLabels",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java
new file mode 100644
index 0000000..cc6a4e8
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesClaimsProducerTest.java
@@ -0,0 +1,191 @@
+/**
+ * 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.producer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.kubernetes.api.model.PersistentVolume;
+import io.fabric8.kubernetes.api.model.PersistentVolumeClaim;
+import io.fabric8.kubernetes.api.model.PersistentVolumeClaimSpec;
+import io.fabric8.kubernetes.api.model.Quantity;
+import io.fabric8.kubernetes.api.model.ResourceRequirements;
+
+import org.apache.camel.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesPersistentVolumesClaimsProducerTest extends
+        KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<PersistentVolumeClaim> result = template.requestBody(
+                "direct:list", "", List.class);
+
+        assertTrue(result.size() == 0);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("component", "elasticsearch");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS,
+                                labels);
+            }
+        });
+
+        List<PersistentVolume> result = ex.getOut().getBody(List.class);
+    }
+
+    @Test
+    public void createListAndDeletePersistentVolumeClaim() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:create", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME,
+                                "test");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS,
+                                labels);
+                PersistentVolumeClaimSpec pvcSpec = new PersistentVolumeClaimSpec();
+                ResourceRequirements rr = new ResourceRequirements();
+                Map<String, Quantity> mp = new HashMap<String, Quantity>();
+                mp.put("storage", new Quantity("100"));
+                rr.setLimits(mp);
+                Map<String, Quantity> req = new HashMap<String, Quantity>();
+                req.put("storage", new Quantity("100"));
+                rr.setRequests(req);
+                pvcSpec.setResources(rr);
+                pvcSpec.setVolumeName("vol001");
+                List<String> access = new ArrayList<String>();
+                access.add("ReadWriteOnce");
+                pvcSpec.setAccessModes(access);
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_SPEC,
+                                pvcSpec);
+            }
+        });
+
+        PersistentVolumeClaim pvc = ex.getOut().getBody(
+                PersistentVolumeClaim.class);
+
+        assertEquals(pvc.getMetadata().getName(), "test");
+
+        ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS,
+                                labels);
+            }
+        });
+
+        List<PersistentVolumeClaim> result = ex.getOut().getBody(List.class);
+
+        boolean pvcExists = false;
+        Iterator<PersistentVolumeClaim> it = result.iterator();
+        while (it.hasNext()) {
+            PersistentVolumeClaim pvcLocal = (PersistentVolumeClaim) it.next();
+            if ("test".equalsIgnoreCase(pvcLocal.getMetadata().getName())) {
+                pvcExists = true;
+            }
+        }
+
+        assertTrue(pvcExists);
+
+        ex = template.request("direct:delete", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME,
+                                "test");
+            }
+        });
+
+        boolean pvcDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(pvcDeleted);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumesClaims&operation=listPersistentVolumesClaims",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumesClaims&operation=listPersistentVolumesClaimsByLabels",
+                                host, authToken);
+                from("direct:create")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumesClaims&operation=createPersistentVolumeClaim",
+                                host, authToken);
+                from("direct:delete")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumesClaims&operation=deletePersistentVolumeClaim",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java
new file mode 100644
index 0000000..1ffb9a5
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPersistentVolumesProducerTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.producer;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import io.fabric8.kubernetes.api.model.PersistentVolume;
+
+import org.apache.camel.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class KubernetesPersistentVolumesProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<PersistentVolume> result = template.requestBody("direct:list", "",
+                List.class);
+
+        assertTrue(result.size() == 1);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("component", "elasticsearch");
+                exchange.getIn()
+                        .setHeader(
+                                KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS,
+                                labels);
+            }
+        });
+
+        List<PersistentVolume> result = ex.getOut().getBody(List.class);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumes&operation=listPersistentVolumes",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=persistentVolumes&operation=listPersistentVolumesByLabels",
+                                host, authToken);
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a452d0ac/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java
new file mode 100644
index 0000000..fc88dd5
--- /dev/null
+++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesPodsProducerTest.java
@@ -0,0 +1,205 @@
+/**
+ * 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.producer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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.Exchange;
+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.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class KubernetesPodsProducerTest extends KubernetesTestSupport {
+
+    @Test
+    public void listTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        List<Pod> result = template.requestBody("direct:list", "", List.class);
+
+        boolean defaultExists = false;
+
+        Iterator<Pod> it = result.iterator();
+        while (it.hasNext()) {
+            Pod pod = (Pod) it.next();
+            if ((pod.getMetadata().getName()).contains("fabric8")) {
+                defaultExists = true;
+            }
+        }
+
+        assertTrue(defaultExists);
+    }
+
+    @Test
+    public void listByLabelsTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:listByLabels", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("component", "elasticsearch");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_PODS_LABELS, labels);
+            }
+        });
+
+        List<Pod> result = ex.getOut().getBody(List.class);
+
+        boolean podExists = false;
+        Iterator<Pod> it = result.iterator();
+        while (it.hasNext()) {
+            Pod pod = (Pod) it.next();
+            if (pod.getMetadata().getLabels().containsValue("elasticsearch")) {
+                podExists = true;
+            }
+        }
+
+        assertFalse(podExists);
+    }
+
+    @Test
+    public void getPodTest() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:getPod", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_NAME,
+                        "elasticsearch-7015o");
+            }
+        });
+
+        Pod result = ex.getOut().getBody(Pod.class);
+
+        assertNull(result);
+    }
+
+    @Test
+    public void createAndDeletePod() throws Exception {
+        if (ObjectHelper.isEmpty(authToken)) {
+            return;
+        }
+        Exchange ex = template.request("direct:createPod", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_NAME, "test");
+                Map<String, String> labels = new HashMap<String, String>();
+                labels.put("this", "rocks");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_PODS_LABELS, labels);
+                PodSpec podSpec = new PodSpec();
+                podSpec.setHost("172.28.128.4");
+                Container cont = new Container();
+                cont.setImage("docker.io/jboss/wildfly:latest");
+                cont.setName("pippo");
+
+                List<ContainerPort> containerPort = new ArrayList<ContainerPort>();
+                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<Container>();
+                list.add(cont);
+
+                podSpec.setContainers(list);
+
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_SPEC, podSpec);
+            }
+        });
+
+        Pod pod = ex.getOut().getBody(Pod.class);
+
+        assertEquals(pod.getMetadata().getName(), "test");
+
+        ex = template.request("direct:deletePod", new Processor() {
+
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
+                        "default");
+                exchange.getIn().setHeader(
+                        KubernetesConstants.KUBERNETES_POD_NAME, "test");
+            }
+        });
+
+        boolean podDeleted = ex.getOut().getBody(Boolean.class);
+
+        assertTrue(podDeleted);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:list")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=listPods",
+                                host, authToken);
+                from("direct:listByLabels")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=listPodsByLabels",
+                                host, authToken);
+                from("direct:getPod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=getPod",
+                                host, authToken);
+                from("direct:createPod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=createPod",
+                                host, authToken);
+                from("direct:deletePod")
+                        .toF("kubernetes://%s?oauthToken=%s&category=pods&operation=deletePod",
+                                host, authToken);
+            }
+        };
+    }
+}


Mime
View raw message