AdvancedCronJob

AdvancedCronJob is an enhanced version of CronJob. The original CronJob creates Job periodically according to schedule rule, but AdvancedCronJob provides template supported multpile job resources.

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: AdvancedCronJob
  3. spec:
  4. template:
  5. # Option 1: use jobTemplate, which is equivalent to original CronJob
  6. jobTemplate:
  7. # ...
  8. # Option 2: use broadcastJobTemplate, which will create a BroadcastJob object when cron schedule triggers
  9. broadcastJobTemplate:
  10. # ...
  11. # Options 3(future): ...
  • jobTemplate:create Jobs periodically, which is equivalent to original CronJob
  • broadcastJobTemplate:create BroadcastJobs periodically, which support to dispatch Jobs on every node

AdvancedCronjob

Example

  1. apiVersion: apps.kruise.io/v1alpha1
  2. kind: AdvancedCronJob
  3. metadata:
  4. name: acj-test
  5. spec:
  6. schedule: "*/1 * * * *"
  7. template:
  8. broadcastJobTemplate:
  9. spec:
  10. template:
  11. spec:
  12. containers:
  13. - name: pi
  14. image: perl
  15. command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
  16. restartPolicy: Never
  17. completionPolicy:
  18. type: Always
  19. ttlSecondsAfterFinished: 30

The YAML below defines an AdvancedCronJob. It will create a BroadcastJob every minute, which will run a job on every node.

Time zones

All CronJob schedule: times are based on the timezone of the kruise-controller-manager by default, which means the timezone set for the kruise-controller-manager container determines the timezone that the cron job controller uses.

FEATURE STATE: Kruise v1.3.0

However, we have introduce a spec.timeZone field in v1.3.0. You can set it to the name of a valid time zone name. For example, setting spec.timeZone: "Etc/UTC" instructs Kruise to interpret the schedule relative to Coordinated Universal Time.

A time zone database from the Go standard library is included in the binaries and used as a fallback in case an external database is not available on the system.