-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const k8s = require("@kubernetes/client-node"); | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const batchV1Api = kc.makeApiClient(k8s.BatchV1Api); | ||
|
||
const namespace = "wifire-mint"; | ||
const jobName = "hello-world-pvc"; | ||
const claimName = "wifire-ensemble-manager"; | ||
|
||
const jobManifest = { | ||
apiVersion: "batch/v1", | ||
kind: "Job", | ||
metadata: { | ||
name: jobName | ||
}, | ||
spec: { | ||
volumes: [ | ||
{ | ||
name: "data", | ||
persistentVolumeClaim: { | ||
claimName: claimName | ||
} | ||
} | ||
], | ||
template: { | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "main", | ||
image: "busybox", | ||
command: ["echo", "Hello, World!"], | ||
volumeMounts: [ | ||
{ | ||
name: "data", | ||
mountPath: "/data" | ||
} | ||
], | ||
resources: { | ||
limits: { | ||
cpu: "200m", // Limit the CPU usage to 200 millicores | ||
memory: "128Mi" // Limit the memory usage to 128 MiB | ||
}, | ||
requests: { | ||
cpu: "100m", // Request at least 100 millicores of CPU | ||
memory: "64Mi" // Request at least 64 MiB of memory | ||
} | ||
} | ||
} | ||
], | ||
volumes: [ | ||
{ | ||
name: "data", | ||
persistentVolumeClaim: { | ||
claimName: claimName | ||
} | ||
} | ||
], | ||
restartPolicy: "Never" | ||
} | ||
}, | ||
backoffLimit: 4 | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
try { | ||
const createRes = await batchV1Api.createNamespacedJob(namespace, jobManifest); | ||
console.log("Job created:", createRes.body.metadata.name); | ||
} catch (err) { | ||
console.error("Error creating job:", err); | ||
} | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const k8s = require("@kubernetes/client-node"); | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const batchV1Api = kc.makeApiClient(k8s.BatchV1Api); | ||
|
||
const namespace = "wifire-mint"; | ||
const jobName = "hello-world"; | ||
|
||
const jobManifest = { | ||
apiVersion: "batch/v1", | ||
kind: "Job", | ||
metadata: { | ||
name: jobName | ||
}, | ||
spec: { | ||
template: { | ||
spec: { | ||
containers: [ | ||
{ | ||
name: "main", | ||
image: "busybox", | ||
command: ["echo", "Hello, World!"], | ||
resources: { | ||
limits: { | ||
cpu: "200m", // Limit the CPU usage to 200 millicores | ||
memory: "128Mi" // Limit the memory usage to 128 MiB | ||
}, | ||
requests: { | ||
cpu: "100m", // Request at least 100 millicores of CPU | ||
memory: "64Mi" // Request at least 64 MiB of memory | ||
} | ||
} | ||
} | ||
], | ||
restartPolicy: "Never" | ||
} | ||
}, | ||
backoffLimit: 4 | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
try { | ||
const createRes = await batchV1Api.createNamespacedJob(namespace, jobManifest); | ||
console.log("Job created:", createRes.body.metadata.name); | ||
} catch (err) { | ||
console.error("Error creating job:", err); | ||
} | ||
}; | ||
|
||
main(); |
File renamed without changes.