Search in sources :

Example 96 with V1Pod

use of io.kubernetes.client.openapi.models.V1Pod 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());
    }
}
Also used : V1PodList(io.kubernetes.client.openapi.models.V1PodList) RE(org.apache.druid.java.util.common.RE) DiscoveryDruidNode(org.apache.druid.discovery.DiscoveryDruidNode) HashMap(java.util.HashMap) V1Pod(io.kubernetes.client.openapi.models.V1Pod) ApiException(io.kubernetes.client.openapi.ApiException)

Aggregations

V1Pod (io.kubernetes.client.openapi.models.V1Pod)96 Test (org.junit.Test)55 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)38 V1PodList (io.kubernetes.client.openapi.models.V1PodList)31 Type (java.lang.reflect.Type)22 ApiException (io.kubernetes.client.openapi.ApiException)17 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)17 V1ListMeta (io.kubernetes.client.openapi.models.V1ListMeta)15 ApiClient (io.kubernetes.client.openapi.ApiClient)12 V1Status (io.kubernetes.client.openapi.models.V1Status)9 Watch (io.kubernetes.client.util.Watch)9 CallGeneratorParams (io.kubernetes.client.util.CallGeneratorParams)8 JSON (io.kubernetes.client.openapi.JSON)7 V1PodSpec (io.kubernetes.client.openapi.models.V1PodSpec)7 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)5 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)4 V1Patch (io.kubernetes.client.custom.V1Patch)4 V1PodBuilder (io.kubernetes.client.openapi.models.V1PodBuilder)4