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