Skip to content

Commit 32fbe49

Browse files
weltekialexellis
authored andcommitted
Add notes on using multiple cron schedules
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent d018e99 commit 32fbe49

File tree

1 file changed

+43
-35
lines changed

1 file changed

+43
-35
lines changed

docs/reference/cron.md

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,66 @@ OpenFaaS Pro adds the ability to have a function invoked by Cron and any other n
1010

1111
* Deploy the connector with arkade or Helm
1212

13-
```sh
14-
arkade install cron-connector
15-
```
13+
```sh
14+
arkade install cron-connector
15+
```
1616

17-
Or deploy for OpenFaaS Pro:
17+
Or deploy for OpenFaaS Pro:
1818

19-
```bash
20-
arkade install cron-connector \
21-
--set openfaasPro=true
22-
```
19+
```bash
20+
arkade install cron-connector \
21+
--set openfaasPro=true
22+
```
2323

24-
Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector)
24+
Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector)
2525

2626
* Now annotate a function with a `topic` of `cron-function` and a `schedule` using a valid CRON expression:
2727

28-
```yaml
29-
# (Abridged YAML)
28+
```yaml
29+
# (Abridged YAML)
3030
31-
functions:
32-
nodeinfo:
33-
image: ghcr.io/openfaas/nodeinfo
34-
skip_build: true
35-
annotations:
36-
topic: cron-function
37-
schedule: "*/5 * * * *"
38-
```
39-
*nodeinfo.yaml*
31+
functions:
32+
nodeinfo:
33+
image: ghcr.io/openfaas/nodeinfo
34+
skip_build: true
35+
annotations:
36+
topic: cron-function
37+
schedule: "*/5 * * * *"
38+
```
39+
*nodeinfo.yaml*
4040

41-
```sh
42-
faas-cli deploy -f nodeinfo.yaml
43-
```
41+
```sh
42+
faas-cli deploy -f nodeinfo.yaml
43+
```
4444

45-
* Or deploy directly from the store
45+
* Or deploy directly from the store
4646

47-
```sh
48-
faas-cli store deploy nodeinfo \
49-
--annotation topic="cron-function" \
50-
--annotation schedule="*/5 * * * *"
51-
```
47+
```sh
48+
faas-cli store deploy nodeinfo \
49+
--annotation topic="cron-function" \
50+
--annotation schedule="*/5 * * * *"
51+
```
5252

5353
* Check the logs for invocations:
5454

55-
```sh
56-
kubectl logs -n openfaas-fn deploy/nodeinfo -f
57-
```
55+
```sh
56+
kubectl logs -n openfaas-fn deploy/nodeinfo -f
57+
```
5858

59-
You'll see the function invoked every 5 minutes as per the schedule.
59+
You'll see the function invoked every 5 minutes as per the schedule.
60+
61+
* Multiple expressions can be added to the `schedule` annotation separated by a semicolon. The connector will schedule invocations for each cron expression.
62+
63+
```sh
64+
faas-cli store deploy nodeinfo \
65+
--annotation topic="cron-function" \
66+
--annotation schedule="*/5 * * * *; * * * * 1,5"
67+
```
6068
6169
* Disable a schedule
6270
63-
To stop the invocations, remove the two annotations or remove the cron-connector deployment.
71+
To disable a schedule, remove the schedule from the `schedule` annotation.
72+
To stop all invocations, remove the `schedule` and `topic` annotations from the function entirely or remove the cron-connector deployment.
6473
6574
6675
If you would like to explore how to write CRON expressions, then see [https://crontab.guru/](https://crontab.guru/)
@@ -244,4 +253,3 @@ spec:
244253
[k8sjob]: https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ "Kuberenetes Jobs"
245254
[faasdeploy]: https://github.com/openfaas/faas-netes/tree/master/chart/openfaas#deploy-openfaas
246255
[nodeinfo]: https://github.com/openfaas/faas/tree/master/sample-functions/NodeInfo
247-

0 commit comments

Comments
 (0)