Skip to content

Commit 832c481

Browse files
authored
Merge pull request #46066 from asem-hamid/adding-job-sidecar.yaml
[bn] Adding example/job files in bn version
2 parents 26ddb4a + 8f61e9a commit 832c481

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: hello
5+
spec:
6+
schedule: "* * * * *"
7+
jobTemplate:
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: hello
13+
image: busybox:1.28
14+
imagePullPolicy: IfNotPresent
15+
command:
16+
- /bin/sh
17+
- -c
18+
- date; echo Hello from the Kubernetes cluster
19+
restartPolicy: OnFailure
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: 'indexed-job'
5+
spec:
6+
completions: 5
7+
parallelism: 3
8+
completionMode: Indexed
9+
template:
10+
spec:
11+
restartPolicy: Never
12+
containers:
13+
- name: 'worker'
14+
image: 'docker.io/library/busybox'
15+
command:
16+
- "rev"
17+
- "/input/data.txt"
18+
volumeMounts:
19+
- mountPath: /input
20+
name: input
21+
volumes:
22+
- name: input
23+
downwardAPI:
24+
items:
25+
- path: "data.txt"
26+
fieldRef:
27+
fieldPath: metadata.annotations['batch.kubernetes.io/job-completion-index']
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: 'indexed-job'
5+
spec:
6+
completions: 5
7+
parallelism: 3
8+
completionMode: Indexed
9+
template:
10+
spec:
11+
restartPolicy: Never
12+
initContainers:
13+
- name: 'input'
14+
image: 'docker.io/library/bash'
15+
command:
16+
- "bash"
17+
- "-c"
18+
- |
19+
items=(foo bar baz qux xyz)
20+
echo ${items[$JOB_COMPLETION_INDEX]} > /input/data.txt
21+
volumeMounts:
22+
- mountPath: /input
23+
name: input
24+
containers:
25+
- name: 'worker'
26+
image: 'docker.io/library/busybox'
27+
command:
28+
- "rev"
29+
- "/input/data.txt"
30+
volumeMounts:
31+
- mountPath: /input
32+
name: input
33+
volumes:
34+
- name: input
35+
emptyDir: {}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: myjob
5+
spec:
6+
template:
7+
spec:
8+
containers:
9+
- name: myjob
10+
image: alpine:latest
11+
command: ['sh', '-c', 'echo "logging" > /opt/logs.txt']
12+
volumeMounts:
13+
- name: data
14+
mountPath: /opt
15+
initContainers:
16+
- name: logshipper
17+
image: alpine:latest
18+
restartPolicy: Always
19+
command: ['sh', '-c', 'tail -F /opt/logs.txt']
20+
volumeMounts:
21+
- name: data
22+
mountPath: /opt
23+
restartPolicy: Never
24+
volumes:
25+
- name: data
26+
emptyDir: {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: process-item-$ITEM
5+
labels:
6+
jobgroup: jobexample
7+
spec:
8+
template:
9+
metadata:
10+
name: jobexample
11+
labels:
12+
jobgroup: jobexample
13+
spec:
14+
containers:
15+
- name: c
16+
image: busybox:1.28
17+
command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"]
18+
restartPolicy: Never

0 commit comments

Comments
 (0)