use of io.kubernetes.client.openapi.models.V1EnvVar in project twister2 by DSC-SPIDAL.
the class JobMasterRequestObject method constructEnvironmentVariables.
/**
* set environment variables for containers
*/
public static List<V1EnvVar> constructEnvironmentVariables(int jvmMem) {
ArrayList<V1EnvVar> envVars = RequestObjectBuilder.getCommonEnvVars();
envVars.add(new V1EnvVar().name(K8sEnvVariables.CONTAINER_NAME.name()).value("twister2-job-master-0"));
envVars.add(new V1EnvVar().name(K8sEnvVariables.CLASS_TO_RUN.name()).value("edu.iu.dsc.tws.rsched.schedulers.k8s.master.JobMasterStarter"));
envVars.add(new V1EnvVar().name(K8sEnvVariables.JVM_MEMORY_MB.name()).value(jvmMem + ""));
return envVars;
}
use of io.kubernetes.client.openapi.models.V1EnvVar in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method getCommonEnvVars.
/**
* add common environment variables to both jm and workers
*/
public static ArrayList<V1EnvVar> getCommonEnvVars() {
ArrayList<V1EnvVar> envVars = new ArrayList<>();
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_ID.name()).value(jobID));
envVars.add(new V1EnvVar().name(K8sEnvVariables.ENCODED_NODE_INFO_LIST.name()).value(encodedNodeInfoList));
// POD_NAME with downward API
V1ObjectFieldSelector fieldSelector = new V1ObjectFieldSelector();
fieldSelector.setFieldPath("metadata.name");
V1EnvVarSource varSource = new V1EnvVarSource();
varSource.setFieldRef(fieldSelector);
envVars.add(new V1EnvVar().name(K8sEnvVariables.POD_NAME.name()).valueFrom(varSource));
// HOST_IP (node-ip) with downward API
fieldSelector = new V1ObjectFieldSelector();
fieldSelector.setFieldPath("status.hostIP");
varSource = new V1EnvVarSource();
varSource.setFieldRef(fieldSelector);
envVars.add(new V1EnvVar().name(K8sEnvVariables.HOST_IP.name()).valueFrom(varSource));
// HOST_NAME (node-name) with downward API
fieldSelector = new V1ObjectFieldSelector();
fieldSelector.setFieldPath("spec.nodeName");
varSource = new V1EnvVarSource();
varSource.setFieldRef(fieldSelector);
envVars.add(new V1EnvVar().name(K8sEnvVariables.HOST_NAME.name()).valueFrom(varSource));
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_PACKAGE_FILE_SIZE.name()).value(jobPackageFileSize + ""));
envVars.add(new V1EnvVar().name(K8sEnvVariables.USER_JOB_JAR_FILE.name()).value(SchedulerContext.userJobJarFile(config)));
envVars.add(new V1EnvVar().name(K8sEnvVariables.POD_MEMORY_VOLUME.name()).value(KubernetesConstants.POD_MEMORY_VOLUME));
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_ARCHIVE_DIRECTORY.name()).value(Context.JOB_ARCHIVE_DIRECTORY));
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_PACKAGE_FILENAME.name()).value(JobUtils.createJobPackageFileName(jobID)));
envVars.add(new V1EnvVar().name(K8sEnvVariables.UPLOAD_METHOD.name()).value(uploadMethod));
String uri = null;
if (SchedulerContext.jobPackageUri(config) != null) {
uri = SchedulerContext.jobPackageUri(config).toString();
}
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_PACKAGE_URI.name()).value(uri));
envVars.add(new V1EnvVar().name(K8sEnvVariables.LOGGER_PROPERTIES_FILE.name()).value(LoggingContext.LOGGER_PROPERTIES_FILE));
envVars.add(new V1EnvVar().name(K8sEnvVariables.JOB_SUBMISSION_TIME.name()).value(jobSubmissionTime + ""));
envVars.add(new V1EnvVar().name(K8sEnvVariables.RESTORE_JOB.name()).value(Boolean.toString(CheckpointingContext.startingFromACheckpoint(config))));
return envVars;
}
Aggregations