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, |
interval |
string |
An interval (for example, |
concurrencyPolicy |
string |
Concurrency policy - |
jobBackoffLimit |
int32 |
The number of retries before failing a job; (default: |
event.body |
string |
The body passed in the event. |
event.headers |
map of string/int |
The headers passed in the event. |
Notes about configuring attributes#
Kubernetes features#
[Tech Preview] On Kubernetes platforms, you can set the cronTriggerCreationMode platform-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