CronJob

CronJobs are jobs which run repeatedly defined by the schedule.

apiVersion: batch/v1
kind: CronJob
metadata:
  name: showtime
  namespace: learning
spec:
  schedule: "*/2 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: showtime
              image: ubuntu
              command: ["date"]
          restartPolicy: Never

jobTemplate takes spec of job which again as spec of pod in its template. It is quite confusing because of this nested specs.

schedule has the format of cron. In the above example, the pod is created every 2nd minute.