Search in sources :

Example 6 with V1ResourceRequirements

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

the class RequestObjectBuilder method createPersistentVolumeClaimObject.

public static V1PersistentVolumeClaim createPersistentVolumeClaimObject(int numberOfWorkers) {
    String pvcName = jobID;
    // set labels for V1PersistentVolumeClaim
    HashMap<String, String> labels = KubernetesUtils.createJobLabels(jobID);
    String storageClass = KubernetesContext.persistentStorageClass(config);
    String accessMode = KubernetesContext.storageAccessMode(config);
    V1ResourceRequirements resources = new V1ResourceRequirements();
    double storageSize = SchedulerContext.persistentVolumePerWorker(config) * numberOfWorkers;
    if (!JobMasterContext.jobMasterRunsInClient(config)) {
        storageSize += JobMasterContext.persistentVolumeSize(config);
    }
    resources.putRequestsItem("storage", new Quantity(storageSize + "Gi"));
    V1PersistentVolumeClaim pvc = new V1PersistentVolumeClaimBuilder().withApiVersion("v1").withNewMetadata().withName(pvcName).withLabels(labels).endMetadata().withNewSpec().withStorageClassName(storageClass).withAccessModes(Arrays.asList(accessMode)).withResources(resources).endSpec().build();
    return pvc;
}
Also used : V1PersistentVolumeClaim(io.kubernetes.client.openapi.models.V1PersistentVolumeClaim) Quantity(io.kubernetes.client.custom.Quantity) V1ResourceRequirements(io.kubernetes.client.openapi.models.V1ResourceRequirements) V1PersistentVolumeClaimBuilder(io.kubernetes.client.openapi.models.V1PersistentVolumeClaimBuilder)

Aggregations

Quantity (io.kubernetes.client.custom.Quantity)6 V1ResourceRequirements (io.kubernetes.client.openapi.models.V1ResourceRequirements)6 V1Container (io.kubernetes.client.openapi.models.V1Container)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 V1ContainerPort (io.kubernetes.client.openapi.models.V1ContainerPort)2 V1PersistentVolumeClaim (io.kubernetes.client.openapi.models.V1PersistentVolumeClaim)2 V1PersistentVolumeClaimBuilder (io.kubernetes.client.openapi.models.V1PersistentVolumeClaimBuilder)2 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)2 ArrayList (java.util.ArrayList)2 IntOrString (io.kubernetes.client.custom.IntOrString)1 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 V1ContainerBuilder (io.kubernetes.client.openapi.models.V1ContainerBuilder)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Config (org.apache.heron.spi.common.Config)1 Resource (org.apache.heron.spi.packing.Resource)1 Test (org.junit.Test)1