From 0134877ab56959b29ea955260bf2bc368e3d308d Mon Sep 17 00:00:00 2001 From: "Han Verstraete (OpenFaaS Ltd)" Date: Mon, 4 Aug 2025 15:56:36 +0200 Subject: [PATCH 1/2] Add notes on using multiple cron schedules Signed-off-by: Han Verstraete (OpenFaaS Ltd) --- docs/reference/cron.md | 78 +++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/docs/reference/cron.md b/docs/reference/cron.md index 51bbbbfb..a87d70f6 100644 --- a/docs/reference/cron.md +++ b/docs/reference/cron.md @@ -10,57 +10,66 @@ OpenFaaS Pro adds the ability to have a function invoked by Cron and any other n * Deploy the connector with arkade or Helm - ```sh - arkade install cron-connector - ``` + ```sh + arkade install cron-connector + ``` - Or deploy for OpenFaaS Pro: + Or deploy for OpenFaaS Pro: - ```bash - arkade install cron-connector \ - --set openfaasPro=true - ``` + ```bash + arkade install cron-connector \ + --set openfaasPro=true + ``` - Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector) + Alternatively, install with the [Helm chart](https://github.com/openfaas/cron-connector) * Now annotate a function with a `topic` of `cron-function` and a `schedule` using a valid CRON expression: - ```yaml - # (Abridged YAML) + ```yaml + # (Abridged YAML) - functions: - nodeinfo: - image: ghcr.io/openfaas/nodeinfo - skip_build: true - annotations: - topic: cron-function - schedule: "*/5 * * * *" - ``` - *nodeinfo.yaml* + functions: + nodeinfo: + image: ghcr.io/openfaas/nodeinfo + skip_build: true + annotations: + topic: cron-function + schedule: "*/5 * * * *" + ``` + *nodeinfo.yaml* - ```sh - faas-cli deploy -f nodeinfo.yaml - ``` + ```sh + faas-cli deploy -f nodeinfo.yaml + ``` - * Or deploy directly from the store +* Or deploy directly from the store - ```sh - faas-cli store deploy nodeinfo \ - --annotation topic="cron-function" \ - --annotation schedule="*/5 * * * *" - ``` + ```sh + faas-cli store deploy nodeinfo \ + --annotation topic="cron-function" \ + --annotation schedule="*/5 * * * *" + ``` * Check the logs for invocations: - ```sh - kubectl logs -n openfaas-fn deploy/nodeinfo -f - ``` + ```sh + kubectl logs -n openfaas-fn deploy/nodeinfo -f + ``` - You'll see the function invoked every 5 minutes as per the schedule. + You'll see the function invoked every 5 minutes as per the schedule. + +* Multiple expressions can be added to the `schedule` annotation separated by a semicolon. The connector will schedule invocations for each cron expression. + + ```sh + faas-cli store deploy nodeinfo \ + --annotation topic="cron-function" \ + --annotation schedule="*/5 * * * *; * * * * 1,5" + ``` * Disable a schedule - To stop the invocations, remove the two annotations or remove the cron-connector deployment. + To disable a schedule, remove the schedule from the `schedule` annotation. + To stop all invocations, remove the `schedule` and `topic` annotations from the function entirely or remove the cron-connector deployment. If you would like to explore how to write CRON expressions, then see [https://crontab.guru/](https://crontab.guru/) @@ -244,4 +253,3 @@ spec: [k8sjob]: https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ "Kuberenetes Jobs" [faasdeploy]: https://github.com/openfaas/faas-netes/tree/master/chart/openfaas#deploy-openfaas [nodeinfo]: https://github.com/openfaas/faas/tree/master/sample-functions/NodeInfo - From afc9e0b239cbef1138c0bfe4bc77b3a6c57d93b9 Mon Sep 17 00:00:00 2001 From: "Han Verstraete (OpenFaaS Ltd)" Date: Mon, 4 Aug 2025 16:02:52 +0200 Subject: [PATCH 2/2] Fix rendering of queue-worker docs Signed-off-by: Han Verstraete (OpenFaaS Ltd) --- docs/openfaas-pro/jetstream.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/openfaas-pro/jetstream.md b/docs/openfaas-pro/jetstream.md index 5b68324a..42db7bc3 100644 --- a/docs/openfaas-pro/jetstream.md +++ b/docs/openfaas-pro/jetstream.md @@ -47,7 +47,8 @@ For staging and development environments OpenFaaS can be deployed with an embedd If the NATS Pod restarts, you will lose all messages that it contains. This could happen if you update the chart and the version of the NATS server has changed, or if a node is removed from the cluster. -** External NATS server** +**External NATS server** + For production environments you should install NATS separately using its Helm chart. NATS can be configured with a quorum of at least 3 replicas so it can recover data if one of the replicas should crash. You can also enable a persistent volume in the NATS chart for additional durability.