Link K8S deps properly
This commit is contained in:
parent
0ac77cdb15
commit
f0260fc819
64 changed files with 4282 additions and 3069 deletions
|
@ -5,22 +5,13 @@
|
|||
"name": "qltr-job-test-suite-1"
|
||||
},
|
||||
"spec": {
|
||||
"ttlSecondsAfterFinished": 2,
|
||||
"template": {
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"resources": {
|
||||
"requests": {
|
||||
"memory": "64MI",
|
||||
"cpu": "250m"
|
||||
},
|
||||
"limits": {
|
||||
"memory": "128MI",
|
||||
"cpu": "500m"
|
||||
}
|
||||
},
|
||||
"name": "qltr-job-test-suite-1",
|
||||
"image": "node",
|
||||
"image": "node:latest",
|
||||
"imagePullPolicy": "Always",
|
||||
"command": ["node", "--version"]
|
||||
}
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
import cp from "node:child_process";
|
||||
import k8s from "@kubernetes/client-node";
|
||||
import { INFO, ERR } from "../../util/logging.js";
|
||||
import { jobBuilder, createFile, deleteFile } from "./k8s-common.js";
|
||||
|
||||
const applyFile = async (filePath) => {
|
||||
const command = `kubectl apply -f ${filePath}`;
|
||||
return new Promise((res, rej) =>
|
||||
cp.exec(command, (err, stdout, stderr) => (err && rej(err)) || res(stdout))
|
||||
);
|
||||
};
|
||||
|
||||
export default async function createJob(jobRequest) {
|
||||
const job = jobBuilder(jobRequest);
|
||||
const filePath = createFile(job);
|
||||
job.spec.template.spec.containers[0].image = "node:latest";
|
||||
job.spec.template.spec.containers[0].command = ["node", "--version"];
|
||||
// job.spec.template.spec.containers[0].image = "reed";
|
||||
// job.spec.template.spec.containers[0].command = "python3 -m pytest -v --tb=no -p no:warnings".split(" ");
|
||||
const kc = new k8s.KubeConfig();
|
||||
kc.loadFromCluster();
|
||||
const batchV1Api = kc.makeApiClient(k8s.BatchV1Api);
|
||||
const batchV1beta1Api = kc.makeApiClient(k8s.BatchV1beta1Api);
|
||||
const jobName = job.metadata.name;
|
||||
batchV1Api
|
||||
.createNamespacedJob("dunestorm-dunemask", job)
|
||||
.then((res) => INFO("K8S", `Job ${jobName} created!`))
|
||||
.catch((err) => ERR("K8S", err));
|
||||
|
||||
/*const filePath = createFile(job);
|
||||
applyFile(filePath);
|
||||
deleteFile(filePath);
|
||||
deleteFile(filePath);*/
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue