A Cron Connector for OpenFaaS
This is a cron event connector for OpenFaaS. This was built to provide a timer interface to trigger OpenFaaS functions. Also checkout OpenFaaS docs on cron for other methods on how you can run functions triggered by cron.
This project was forked from zeerorg/cron-connector to enable prompt updates and patches for end-users.
How to Use
You need to have OpenFaaS deployed first, see https://docs.openfaas.com to get started
Works with both AMD64 and armhf (Raspberry Pi).
- For Docker Swarm:
curl -s https://raw.githubusercontent.com/openfaas-incubator/cron-connector/master/yaml/docker-compose.yml | docker stack deploy func -c -
- For Kubernetes:
curl -s https://raw.githubusercontent.com/openfaas-incubator/cron-connector/master/yaml/kubernetes/connector-dep.yml | kubectl apply -f -
The function should have 2 annotations:
topicannotation should be
scheduleannotation should be the cron schedule on which to invoke function
For example, we may have a function "nodeinfo" which we want to invoke every 5 minutes:
Deploy via the CLI:
faas-cli store deploy nodeinfo --annotation schedule="*/5 * * * *" --annotation topic=cron-function
functions: nodeinfo: image: functions/nodeinfo annotations: topic: cron-function schedule: "*/5 * * * *"
You can learn how to create and test the Cron syntax here.
See the full example here: sample/stack.yml
The helm chart is available in the faas-netes repo.