Search in sources :

Example 6 with V1ConfigMapList

use of io.kubernetes.client.openapi.models.V1ConfigMapList in project twister2 by DSC-SPIDAL.

the class KubernetesController method existConfigMap.

/**
 * return true if there is already a ConfigMap object with the same name on Kubernetes master,
 * otherwise return false
 */
public boolean existConfigMap(String jobID) {
    String configMapName = jobID;
    V1ConfigMapList configMapList = null;
    try {
        configMapList = coreApi.listNamespacedConfigMap(namespace, null, null, null, null, null, null, null, null, null);
    } catch (ApiException e) {
        LOG.log(Level.SEVERE, "Exception when getting ConfigMap list.", e);
        throw new RuntimeException(e);
    }
    for (V1ConfigMap configMap : configMapList.getItems()) {
        if (configMapName.equals(configMap.getMetadata().getName())) {
            return true;
        }
    }
    return false;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) V1ConfigMapList(io.kubernetes.client.openapi.models.V1ConfigMapList) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) ApiException(io.kubernetes.client.openapi.ApiException)

Aggregations

V1ConfigMapList (io.kubernetes.client.openapi.models.V1ConfigMapList)6 Type (java.lang.reflect.Type)4 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)2 Parameters (com.github.tomakehurst.wiremock.extension.Parameters)1 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)1 ApiException (io.kubernetes.client.openapi.ApiException)1 JSON (io.kubernetes.client.openapi.JSON)1 V1ListMeta (io.kubernetes.client.openapi.models.V1ListMeta)1 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 V1PodList (io.kubernetes.client.openapi.models.V1PodList)1 Semaphore (java.util.concurrent.Semaphore)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1