Search in sources :

Example 6 with V1EnvVar

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;
}
Also used : V1EnvVar(io.kubernetes.client.openapi.models.V1EnvVar)

Example 7 with V1EnvVar

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;
}
Also used : V1EnvVarSource(io.kubernetes.client.openapi.models.V1EnvVarSource) ArrayList(java.util.ArrayList) V1ObjectFieldSelector(io.kubernetes.client.openapi.models.V1ObjectFieldSelector) V1EnvVar(io.kubernetes.client.openapi.models.V1EnvVar)

Aggregations

V1EnvVar (io.kubernetes.client.openapi.models.V1EnvVar)7 V1EnvVarSource (io.kubernetes.client.openapi.models.V1EnvVarSource)5 V1ObjectFieldSelector (io.kubernetes.client.openapi.models.V1ObjectFieldSelector)4 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)1 V1Container (io.kubernetes.client.openapi.models.V1Container)1 V1ContainerBuilder (io.kubernetes.client.openapi.models.V1ContainerBuilder)1 V1SecretKeySelector (io.kubernetes.client.openapi.models.V1SecretKeySelector)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TopologyRuntimeManagementException (org.apache.heron.scheduler.TopologyRuntimeManagementException)1 TopologySubmissionException (org.apache.heron.scheduler.TopologySubmissionException)1 Config (org.apache.heron.spi.common.Config)1