Skip to content

Instantly share code, notes, and snippets.

@odacremolbap
Last active September 26, 2017 11:36
Show Gist options
  • Save odacremolbap/1c75dfce543a8d480ab69eab323c691b to your computer and use it in GitHub Desktop.
Save odacremolbap/1c75dfce543a8d480ab69eab323c691b to your computer and use it in GitHub Desktop.
Job templates
# CRON JOBS
# Simple
apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: simplecj
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: simplecj
image: busybox
args:
- /bin/sh
- -c
- date; echo howdy
restartPolicy: OnFailure
# JOBS
## Simple Job
apiVersion: batch/v1
kind: Job
metadata:
name: simplej
spec:
template:
metadata:
name: simplej
spec:
containers:
- name: simplej
image: busybox
command: ["sh", "-c", "echo This job is completed now"]
restartPolicy: Never
## Simple Job with multiple completions
apiVersion: batch/v1
kind: Job
metadata:
name: simple20
spec:
completions: 20
template:
metadata:
name: simple20
spec:
containers:
- name: simple20
image: busybox
command: ["sh", "-c", "echo This job is simple x 20"]
restartPolicy: Never
## Parallel Job
apiVersion: batch/v1
kind: Job
metadata:
name: parallelj
spec:
completions: 20
parallelism: 10
template:
metadata:
name: parallelj
spec:
containers:
- name: parallelj
image: busybox
command: ["sh", "-c", "echo This job is parallelized"]
restartPolicy: Never
## Timeline exceeded Job
apiVersion: batch/v1
kind: Job
metadata:
name: deadline
spec:
activeDeadlineSeconds: 20
template:
metadata:
name: deadline
spec:
containers:
- name: deadline
image: busybox
command: ["sh", "-c", "sleep 5;exit 2"]
restartPolicy: Never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment