-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJobCreate.java
31 lines (28 loc) · 1.14 KB
/
JobCreate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package io.fabric8;
import io.fabric8.kubernetes.api.model.batch.v1.Job;
import io.fabric8.kubernetes.api.model.batch.v1.JobBuilder;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
public class JobCreate {
public static void main(String[] args) {
try (KubernetesClient client = new KubernetesClientBuilder().build()) {
Job job = new JobBuilder()
.withNewMetadata().withName("pi").endMetadata()
.withNewSpec()
.withNewTemplate()
.withNewSpec()
.addNewContainer()
.withName("pi")
.withImage("perl")
.withCommand("perl", "-Mbignum=bpi", "-wle", "print bpi(2000)")
.endContainer()
.withRestartPolicy("Never")
.endSpec()
.endTemplate()
.withBackoffLimit(4)
.endSpec()
.build();
client.batch().v1().jobs().inNamespace("default").resource(job).create();
}
}
}