Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/openfaas-pro/jetstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
78 changes: 43 additions & 35 deletions docs/reference/cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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