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());
}
Aggregations