You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* deploy nodeinfo from store instead of using a YAML file,
for brevity
* link to K8s docs for cron jobs
* correct a typo
* set a pull policy that makes more sense for the example
given
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
Copy file name to clipboardExpand all lines: docs/reference/cron.md
+10-25Lines changed: 10 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,34 +6,18 @@ If you are deploying OpenFaaS to [Kubernetes][k8s], then we can easily run funct
6
6
7
7
We assume that you have used the [recommended install of `faas-netes`][faasdeploy] which means that you have OpenFaaS deployed into two namespaces:
8
8
9
-
1.`openfaas` for the core componentes (ui, gateway, etc)
9
+
1.`openfaas` for the core components (ui, gateway, etc)
10
10
2.`openfaas-fn` for the function deployments
11
11
12
12
### Simple Cron Job
13
13
14
-
For this example, we use the [sample `nodeinfo`function][nodeinfo], which can be deployed using this stack file
14
+
For this example we'll deploy a function which can print system info about the container it's running in:
15
15
16
-
```yaml
17
-
# stack.yaml
18
-
provider:
19
-
name: openfaas
20
-
gateway: http://gateway.openfaas.local
21
-
22
-
functions:
23
-
nodeinfo:
24
-
lang: dockerfile
25
-
handler: node main.js
26
-
image: functions/nodeinfo:latest
27
-
skip_build: true
28
-
```
29
-
30
-
and the cli
31
-
32
-
```yaml
33
-
$ faas deploy
16
+
```bash
17
+
faas-cli store deploy nodeinfo
34
18
```
35
19
36
-
We can then define a Kubernetes cron job to call this function every minute using this manifest file:
20
+
We can then define a [Kubernetes cron job](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) to call this function every minute using this manifest file:
37
21
38
22
```yaml
39
23
# node-cron.yaml
@@ -53,7 +37,8 @@ spec:
53
37
spec:
54
38
containers:
55
39
- name: openfaas-cli
56
-
image: openfaas/faas-cli:0.8.3
40
+
image: openfaas/faas-cli:latest
41
+
imagePullPolicy: IfNotPresent
57
42
command:
58
43
- /bin/sh
59
44
args:
@@ -64,12 +49,13 @@ spec:
64
49
65
50
You should also update the `image` to the latest version of the `faas-cli` available found via the [Docker Hub](https://hub.docker.com/r/openfaas/faas-cli/tags/) or [faas-cli releases](https://github.com/openfaas/faas-cli/releases) page.
66
51
67
-
The important thing to notice is that we are using a Docker container with the `faas-cli` to invoke the function. This keeps the job very generic and easy to generize to other functions.
52
+
The important thing to notice is that we are using a Docker container with the `faas-cli` to invoke the function. This keeps the job very generic.
68
53
69
54
We schedule the job by applying our manifest
70
55
71
56
```sh
72
57
$ kubectl apply -f node-cron.yaml
58
+
73
59
$ kubectl -n=openfaas get cronjob nodeinfo --watch
0 commit comments