...

Kubernetes 101 – Jobs & Cronjobs

ob

A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate.

apiVersion: batch/v1

kind: Job

metadata:

name: job

spec:

template:

containers:

– name: nginx

image: nginx:latest

command: [”/bin/sh”, “-c”, “date;”]

backoffLimit: 4

As pods successfully complete, the Job tracks the successful completions.

When a specified number of successful completions is reached, the task (Job) is complete.
CronJob

A CronJob creates Jobs on a repeating schedule.

apiVersion: batch/v1

kind: CronJob

metadata:

name: cronjob

spec:

schedule: “*/1 * * * *”

jobTemplate:

spec:

template:

spec:

containers:

– name: nginx

image: nginx:latest

command: [”/bin/sh”, “-c”, “date;”]

CronJobs are meant for performing regular scheduled actions such as backups, report generation, and so on.

Each of those tasks should be configured to recur indefinitely (for example: once a day / week / month).
Follow the Kubernetes 101 series on mindit.io.

Check out new-spike.net for other articles on Kubernetes and much more!

Distribute:

/turn your vision into reality

The best way to start a long-term collaboration is with a Pilot project. Let’s talk.