Commit c4f49f63 authored by Koehorst, Jasper's avatar Koehorst, Jasper
Browse files

jobmanager removal

parent da74f34b
Pipeline #23258 passed with stage
in 2 minutes and 12 seconds
......@@ -20,8 +20,6 @@ public class App {
} else if (Arrays.asList(args).contains("-kubernetes")) {
log.info("Executing kubernetes workflows");
nl.munlock.kubernetes.App.main(args);
} else if (Arrays.asList(args).contains("-manager")) {
nl.munlock.kubernetes.App.manager();
}
}
}
......@@ -28,118 +28,4 @@ public class App {
Connection connection = new Connection(commandOptions);
Kubernetes.main(commandOptions, connection);
}
/**
* Method to start the cron job manager basically executes this program on a kubernetes cluster for all projects
*/
public static void manager() throws ApiException, IOException {
V1PodTemplateSpec template = new V1PodTemplateSpec();
// Defines the docker container
V1Container containerItem = new V1Container();
containerItem.name("jobmanager");
containerItem.image("docker-registry.wur.nl/unlock/docker");
V1ResourceRequirements resource = new V1ResourceRequirements();
// Set limits to the job
Map<String, Quantity> limit = new HashMap<>();
Quantity quantity_cpu = new Quantity(2000 + "m");
Quantity quantity_mem = new Quantity(1000 + "Mi");
limit.put("cpu", quantity_cpu);
limit.put("memory", quantity_mem);
resource.limits(limit);
// Set requests for the job
Map<String, Quantity> request = new HashMap<>();
quantity_mem = new Quantity(1000 + "Mi");
quantity_cpu = new Quantity(2000 + "m");
request.put("memory", quantity_mem);
request.put("cpu", quantity_cpu);
resource.requests(request);
containerItem.resources(resource);
// List of arguments for the command during startup
List<String> args = new ArrayList<>();
// Execute.sh should sync the collection after the run
args.add("/scripts/jobManager.sh");
containerItem.args(args);
// Base command
List<String> command = new ArrayList<>();
command.add("bash");
containerItem.command(command);
// Unlock mount
containerItem.addVolumeMountsItem(new V1VolumeMount().name("unlock").mountPath("/unlock"));
// Environmental path for java etc...
HashMap<String, String> envMap = new HashMap<>();
envMap.put("PATH", "/root/.sdkman/candidates/maven/current/bin:/root/.sdkman/candidates/java/current/bin:/root/.sdkman/candidates/gradle/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
List<V1EnvVar> env = new ArrayList();
for (String key : envMap.keySet()) {
V1EnvVar v1EnvVar = new V1EnvVar();
v1EnvVar.setName(key);
v1EnvVar.setValue(envMap.get(key));
env.add(v1EnvVar);
}
containerItem.env(env);
// Set the name
containerItem.name("jobmanager");
// Setting secrets
containerItem.addEnvItem(setSecret("irodsHost","unlock-secret", "irodsHost"));
containerItem.addEnvItem(setSecret("irodsPort","unlock-secret", "irodsPort"));
containerItem.addEnvItem(setSecret("irodsUserName","unlock-secret", "irodsUserName"));
containerItem.addEnvItem(setSecret("irodsZone","unlock-secret", "irodsZone"));
containerItem.addEnvItem(setSecret("irodsAuthScheme","unlock-secret", "irodsAuthScheme"));
containerItem.addEnvItem(setSecret("irodsHome","unlock-secret", "irodsHome"));
containerItem.addEnvItem(setSecret("irodsCwd","unlock-secret", "irodsCwd"));
containerItem.addEnvItem(setSecret("irodsPassword","unlock-secret", "irodsPassword"));
containerItem.addEnvItem(setSecret("irodsSSL","unlock-secret", "irodsSSL"));
// Job specifications
V1JobSpec v1JobSpec = new V1JobSpec();
v1JobSpec.ttlSecondsAfterFinished(1000);
v1JobSpec.setTtlSecondsAfterFinished(1000);
v1JobSpec.setBackoffLimit(1);
// 60 min runtime, disabled as when queue is large jobs get killed when not even started
// specs.activeDeadlineSeconds((long) 3600);
v1JobSpec.template(template);
V1PodSpec v1PodSpec = new V1PodSpec();
// https://rancher.com/docs/k3s/latest/en/storage/
v1PodSpec.addVolumesItem(new V1Volume().name("unlock").persistentVolumeClaim(new V1PersistentVolumeClaimVolumeSource().claimName("unlock")));
v1PodSpec.addContainersItem(containerItem);
v1PodSpec.restartPolicy("OnFailure");
template.spec(v1PodSpec);
// Set priority level
// v1PodSpec.setPriority(commandOptions.priority);
V1ObjectMeta v1ObjectMeta = new V1ObjectMeta();
v1ObjectMeta.generateName("jobmanager");
V1Job v1Job = new V1Job();
v1Job.apiVersion("batch/v1");
v1Job.kind("Job");
v1Job.metadata(v1ObjectMeta);
v1Job.spec(v1JobSpec);
// Load and make connection
ApiClient client = Config.defaultClient();
client.setDebugging(true);
Configuration.setDefaultApiClient(client);
// v1Job.setKind("my-kind");
BatchV1Api batchV1Api = new BatchV1Api();
// Submit the job to nl.wur.ssb.kubernetes
batchV1Api.createNamespacedJob("unlock", v1Job, false, null, null);
batchV1Api.createNamespacedJobCall("unlock", v1Job, null, null, null, null, null);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment