Skip to content

Commit 700c543

Browse files
committed
Update CLI instructions
* 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>
1 parent 9aafd06 commit 700c543

1 file changed

Lines changed: 10 additions & 25 deletions

File tree

docs/reference/cron.md

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,18 @@ If you are deploying OpenFaaS to [Kubernetes][k8s], then we can easily run funct
66

77
We assume that you have used the [recommended install of `faas-netes`][faasdeploy] which means that you have OpenFaaS deployed into two namespaces:
88

9-
1. `openfaas` for the core componentes (ui, gateway, etc)
9+
1. `openfaas` for the core components (ui, gateway, etc)
1010
2. `openfaas-fn` for the function deployments
1111

1212
### Simple Cron Job
1313

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:
1515

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
3418
```
3519

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:
3721

3822
```yaml
3923
# node-cron.yaml
@@ -53,7 +37,8 @@ spec:
5337
spec:
5438
containers:
5539
- name: openfaas-cli
56-
image: openfaas/faas-cli:0.8.3
40+
image: openfaas/faas-cli:latest
41+
imagePullPolicy: IfNotPresent
5742
command:
5843
- /bin/sh
5944
args:
@@ -64,12 +49,13 @@ spec:
6449
6550
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.
6651

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.
6853

6954
We schedule the job by applying our manifest
7055

7156
```sh
7257
$ kubectl apply -f node-cron.yaml
58+
7359
$ kubectl -n=openfaas get cronjob nodeinfo --watch
7460
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
7561
nodeinfo */1 * * * * False 0 <none> 42s
@@ -173,9 +159,8 @@ spec:
173159
secretKeyRef:
174160
name: basic-auth
175161
key: basic-auth-password
176-
command:
177-
- /bin/sh
178162
args:
163+
- /bin/sh
179164
- -c
180165
- echo -n $PASSWORD | faas-cli login -g http://gateway.openfaas:8080 -u $USERNAME --password-stdin
181166
- echo "verbose" | faas-cli invoke nodeinfo -g http://gateway.openfaas:8080

0 commit comments

Comments
 (0)