use of io.kubernetes.client.openapi.models.V1PodList in project java by kubernetes-client.
the class ExpandedExample method getPods.
/**
* List all pod names in all namespaces in k8s cluster
*
* @return
* @throws ApiException
*/
public static List<String> getPods() throws ApiException {
V1PodList v1podList = COREV1_API.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null);
List<String> podList = v1podList.getItems().stream().map(v1Pod -> v1Pod.getMetadata().getName()).collect(Collectors.toList());
return podList;
}
use of io.kubernetes.client.openapi.models.V1PodList in project druid by druid-io.
the class DefaultK8sApiClient method listPods.
@Override
public DiscoveryDruidNodeList listPods(String podNamespace, String labelSelector, NodeRole nodeRole) {
try {
V1PodList podList = coreV1Api.listNamespacedPod(podNamespace, null, null, null, null, labelSelector, 0, null, null, null);
Preconditions.checkState(podList != null, "WTH: NULL podList");
Map<String, DiscoveryDruidNode> allNodes = new HashMap();
for (V1Pod podDef : podList.getItems()) {
DiscoveryDruidNode node = getDiscoveryDruidNodeFromPodDef(nodeRole, podDef);
allNodes.put(node.getDruidNode().getHostAndPortToUse(), node);
}
return new DiscoveryDruidNodeList(podList.getMetadata().getResourceVersion(), allNodes);
} catch (ApiException ex) {
throw new RE(ex, "Expection in listing pods, code[%d] and error[%s].", ex.getCode(), ex.getResponseBody());
}
}
Aggregations