Jobs and CronJobs
Jobs
A Job creates one or more Pods and ensures that a specified number of them successfully terminate. As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created.
CronJobs
One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format.
All CronJob schedule: times are based on the timezone of the master where the job is initiated.
Resources
References
It computes π to 2000 places and prints it out
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
Running in parallel
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
parallelism: 2
completions: 3
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
Gets Jobs
Gets Job Description Gets Pods from the Job Deletes Job Gets CronJob Describes CronJob Gets Pods from CronJob Deletes CronJobGets Jobs
Gets Job Description Gets Pods from the Job Deletes Job Gets CronJob Describes CronJob Gets Pods from CronJob Deletes CronJobActivities
Task | Description | Link |
---|---|---|
Try It Yourself | ||
Rolling Updates Lab | Create a Rolling Update for your application. | Rolling Updates |
Cron Jobs Lab | Using Tekton to test new versions of applications. | Crons Jobs |