Skip to content

Commit 8aebe07

Browse files
committed
Add an example showing how to create Jobs using KRO. Note we need to make sure the job stays by not setting any TTL (#540)
1 parent 1dc6047 commit 8aebe07

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kro.run/v1alpha1
2+
kind: JobDeployment
3+
metadata:
4+
name: example-job-deployment
5+
spec:
6+
replicas: 2
7+
delayInSeconds: 20
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: kro.run/v1alpha1
2+
kind: ResourceGraphDefinition
3+
metadata:
4+
name: job-deployment.kro.run
5+
spec:
6+
schema:
7+
apiVersion: v1alpha1
8+
kind: JobDeployment
9+
spec:
10+
replicas: integer | default=1
11+
delayInSeconds: integer | default=30
12+
resources:
13+
- id: job
14+
readyWhen:
15+
- ${job.status.completionTime != null}
16+
template:
17+
apiVersion: batch/v1
18+
kind: Job
19+
metadata:
20+
name: ${schema.metadata.name}-job
21+
spec:
22+
# NOTE: will not work if we delete the job after it finishes. It will try to recreate the job.
23+
#ttlSecondsAfterFinished: 30
24+
template:
25+
spec:
26+
restartPolicy: Never
27+
containers:
28+
- name: sleeper
29+
image: busybox
30+
command: ["sleep", "${string(schema.spec.delayInSeconds)}"]
31+
resources:
32+
limits:
33+
cpu: "1"
34+
- id: deployment
35+
template:
36+
apiVersion: apps/v1
37+
kind: Deployment
38+
metadata:
39+
name: ${schema.metadata.name}
40+
spec:
41+
replicas: ${schema.spec.replicas}
42+
selector:
43+
matchLabels:
44+
app: ${schema.metadata.name}
45+
template:
46+
metadata:
47+
labels:
48+
app: ${schema.metadata.name}
49+
spec:
50+
containers:
51+
- name: web
52+
image: nginx
53+
ports:
54+
- containerPort: 80

0 commit comments

Comments
 (0)