A Kubernetes Job is a controller object that represents a finite task. Jobs differ from other controller objects in that Jobs manage a task as it runs to completion, rather than managing a desired state such as in Deployments, ReplicaSets, and StatefulSets do. When a specified number of successful completions is reached, the Job is complete. Kubernetes Jobs are used when you want to create pods that will do a specific task and then exit.

apiVersion: batch/v1
kind: Job
  name: pi
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never
  backoffLimit: 4

Cronjobs: Automating Kubernetes Jobs

CronJob creates Jobs on a repeating schedule. The automated Jobs run like Cron tasks on a Linux or UNIX system.

CronJobs are useful for creating periodic and recurring tasks, like running backups or sending emails. CronJobs can also schedule individual tasks for a specific time, such as if you want to schedule a job for a low activity period.

A CronJob creates a Job object once per execution time of its schedule. The .spec.successfulJobsHistoryLimit and .spec.failedJobsHistoryLimit fields specify how many completed and failed jobs should be kept. By default, they are set to 3 and 1 respectively.

#kubernetes #jobs #monitoring

Monitoring Kubernetes Jobs
1.65 GEEK