Cron trigger#
In this document#
Overview#
Triggers the function according to a schedule or interval, with an optional body.
Attributes#
| Path | Type | Description |
|---|---|---|
| schedule | string | A cron-like schedule (for example, */5 * * * *). |
| interval | string | An interval (for example, 1s, 30m). |
| concurrencyPolicy | string | Concurrency policy - "Allow", "Forbid", or "Replace"; (default: "Forbid"). Applicable only when using CronJobs on Kubernetes platforms (see the Kubernetes notes). |
| jobBackoffLimit | int32 | The number of retries before failing a job; (default: 2). Applicable only when using CronJobs on Kubernetes platforms (see the Kubernetes notes). |
| event.body | string | The body passed in the event. |
| event.headers | map of string/int | The headers passed in the event. |
Note:
You must set either the
scheduleorintervalmutually-exclusive attributes.[Tech Preview] On Kubernetes platforms, you can set the
cronTriggerCreationModeplatform-configuration field to"kube"to run the triggers as Kubernetes CronJobs instead of the default implementation of running Cron triggers from the Nuclio processor. For more information, see Configuring a Platform. When running Cron triggers as CronJobs —
The created CronJob uses
wgetto call the default HTTP trigger of the function according to the configured interval or schedule. (This means that worker-related attributes are irrelevant.)The
wgetrequest is sent with the header"x-nuclio-invoke-trigger: cron".You can use the
concurrencyPolicyandjobBackoffLimitattributes to configure the CronJobs.
Examples#
triggers:
myCronTrigger:
kind: cron
attributes:
interval: 3s
The following example is demonstrates a configuration for running Cron triggers as Kubernetes CronJobs, as it sets the concurrencyPolicy and jobBackoffLimit attributes.
Remember that this implementation requires setting the cronTriggerCreationMode platform-configuration field to "kube".
See the Kubernetes notes.
triggers:
myCronTrigger:
kind: cron
attributes:
interval: 10s
concurrencyPolicy: "Allow"
jobBackoffLimit: 2