Search in sources :

Example 1 with PodResource

use of io.fabric8.kubernetes.client.dsl.PodResource in project camel by apache.

the class KubernetesPodsProducer method doListPodsByLabel.

protected void doListPodsByLabel(Exchange exchange, String operation) {
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PODS_LABELS, Map.class);
    if (ObjectHelper.isEmpty(labels)) {
        LOG.error("Get pods by labels require specify a labels set");
        throw new IllegalArgumentException("Get pods by labels require specify a labels set");
    }
    MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = getEndpoint().getKubernetesClient().pods();
    for (Map.Entry<String, String> entry : labels.entrySet()) {
        pods.withLabel(entry.getKey(), entry.getValue());
    }
    PodList podList = pods.list();
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(podList.getItems());
}
Also used : PodList(io.fabric8.kubernetes.api.model.PodList) PodResource(io.fabric8.kubernetes.client.dsl.PodResource) DoneablePod(io.fabric8.kubernetes.api.model.DoneablePod) Pod(io.fabric8.kubernetes.api.model.Pod) DoneablePod(io.fabric8.kubernetes.api.model.DoneablePod) Map(java.util.Map)

Aggregations

DoneablePod (io.fabric8.kubernetes.api.model.DoneablePod)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 PodList (io.fabric8.kubernetes.api.model.PodList)1 PodResource (io.fabric8.kubernetes.client.dsl.PodResource)1 Map (java.util.Map)1