Search in sources :

Example 1 with ReplicationControllerList

use of io.fabric8.kubernetes.api.model.ReplicationControllerList in project camel by apache.

the class KubernetesReplicationControllersProducer method doList.

protected void doList(Exchange exchange, String operation) throws Exception {
    ReplicationControllerList rcList = null;
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        rcList = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName).list();
    } else {
        rcList = getEndpoint().getKubernetesClient().replicationControllers().list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(rcList.getItems());
}
Also used : ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList)

Example 2 with ReplicationControllerList

use of io.fabric8.kubernetes.api.model.ReplicationControllerList in project fabric8 by fabric8io.

the class Example method listReplicationControllers.

protected static void listReplicationControllers(KubernetesClient kube) {
    System.out.println("\n\nLooking up replicationControllers");
    System.out.println("=========================================================================");
    ReplicationControllerList replicationControllers = kube.replicationControllers().list();
    List<ReplicationController> items = replicationControllers.getItems();
    for (ReplicationController item : items) {
        ReplicationControllerSpec replicationControllerSpec = item.getSpec();
        if (replicationControllerSpec != null) {
            System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() + " replicas: " + replicationControllerSpec.getReplicas() + " replicatorSelector: " + replicationControllerSpec.getSelector() + " podTemplate: " + replicationControllerSpec.getTemplate());
        } else {
            System.out.println("ReplicationController " + KubernetesHelper.getName(item) + " labels: " + item.getMetadata().getLabels() + " no replicationControllerSpec");
        }
    }
    System.out.println();
}
Also used : ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList) ReplicationControllerSpec(io.fabric8.kubernetes.api.model.ReplicationControllerSpec)

Example 3 with ReplicationControllerList

use of io.fabric8.kubernetes.api.model.ReplicationControllerList in project camel by apache.

the class KubernetesReplicationControllersProducer method doListReplicationControllersByLabels.

protected void doListReplicationControllersByLabels(Exchange exchange, String operation) throws Exception {
    ReplicationControllerList rcList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
        replicationControllers = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            replicationControllers.withLabel(entry.getKey(), entry.getValue());
        }
        rcList = replicationControllers.list();
    } else {
        MixedOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
        replicationControllers = getEndpoint().getKubernetesClient().replicationControllers();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            replicationControllers.withLabel(entry.getKey(), entry.getValue());
        }
        rcList = replicationControllers.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(rcList.getItems());
}
Also used : DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) RollableScallableResource(io.fabric8.kubernetes.client.dsl.RollableScallableResource) Map(java.util.Map) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList) DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController)

Example 4 with ReplicationControllerList

use of io.fabric8.kubernetes.api.model.ReplicationControllerList in project fabric8 by fabric8io.

the class KubernetesAssert method replicationControllers.

public ListAssert<ReplicationController> replicationControllers() {
    ReplicationControllerList replicationControllerList = client.replicationControllers().inNamespace(namespace()).list();
    assertThat(replicationControllerList).isNotNull();
    List<ReplicationController> replicationControllers = replicationControllerList.getItems();
    return (ListAssert<ReplicationController>) assertThat(replicationControllers);
}
Also used : ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ReplicationControllerListAssert(io.fabric8.kubernetes.api.model.ReplicationControllerListAssert) ServiceListAssert(io.fabric8.kubernetes.api.model.ServiceListAssert) ListAssert(org.assertj.core.api.ListAssert) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList)

Aggregations

ReplicationControllerList (io.fabric8.kubernetes.api.model.ReplicationControllerList)4 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)3 DoneableReplicationController (io.fabric8.kubernetes.api.model.DoneableReplicationController)1 ReplicationControllerListAssert (io.fabric8.kubernetes.api.model.ReplicationControllerListAssert)1 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)1 ServiceListAssert (io.fabric8.kubernetes.api.model.ServiceListAssert)1 RollableScallableResource (io.fabric8.kubernetes.client.dsl.RollableScallableResource)1 Map (java.util.Map)1 ListAssert (org.assertj.core.api.ListAssert)1