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
Copy file name to clipboardExpand all lines: docs/reference/workloads.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,14 @@ All workloads must:
9
9
* serve HTTP traffic on TCP port 8080
10
10
* assume ephemeral storage
11
11
* be stateless
12
+
* have a name of no more than 63 characters
12
13
13
14
And integrate with a health-check mechanism with Kubernetes:
14
15
15
-
*or enable httpProbe in the `helm` chart and implement `/_/health` as a HTTP endpoint
16
-
*create a lock file in `/tmp/.lock` - removing this file signals service degradation
16
+
* implement `/_/health` as a HTTP endpoint
17
+
*implement `/_/ready` as a HTTP endpoint
17
18
18
-
> Note: You can specify a custom HTTP Path for the health-check using the `com.openfaas.health.http.path` annotation
19
+
The path for the HTTP ready and health endpoints can be overridden with annotations (see below)
19
20
20
21
If running in read-only mode, then you can write files to the `/tmp/` mount only. These files may be accessible upon subsequent requests but it is not guaranteed. For instance - if you have two replicas of a function then both may have different contents in their `/tmp/` mount. When running without read-only mode you can write files to the user's home directory subject to the same rules.
21
22
@@ -39,9 +40,11 @@ Custom binaries can also be used as a function. Just use the `dockerfile` langua
39
40
40
41
### Running an existing Docker image on OpenFaaS
41
42
42
-
Let's take a Node.js app which listens on traffic using port 3000, and assume that we can't make any changes to it.
43
+
If you can change the code in your application, you'll need to add a health and readiness endpoint, along with changing its HTTP port to listen on 8080, then you can deploy it directly to OpenFaaS.
43
44
44
-
You can view its Dockerfile and code at: [alexellis/expressjs-k8s](https://github.com/alexellis/expressjs-k8s/) and the image is published to the Docker Hub at: `alexellis2/service:0.3.6`
45
+
Let's assume you cannot change any code, and have a Node.js application that listens to traffic on port 3000. We can use the OpenFaaS of-watchdog in HTTP mode to proxy traffic to the process and to provide health checks.
46
+
47
+
You can view its Dockerfile and code at: [alexellis/expressjs-k8s](https://github.com/alexellis/expressjs-k8s) and the image is published to the Docker Hub at: `alexellis2/service:0.3.6`
45
48
46
49
Start by creating a new folder:
47
50
@@ -53,10 +56,10 @@ Write a custom Dockerfile `./node-service/Dockerfile`:
53
56
54
57
```Dockerfile
55
58
# Import the OpenFaaS of-watchdog
56
-
FROM openfaas/of-watchdog:0.7.2 as watchdog
59
+
FROMghcr.io/openfaas/of-watchdog:0.9.16 as watchdog
57
60
58
61
# Add a FROM line from your existing image
59
-
FROM alexellis2/service:0.3.6
62
+
FROM alexellis2/service:0.4.1
60
63
61
64
# Let's say that the image listens on port 3000 and
62
65
# that we can't change that easily
@@ -91,7 +94,7 @@ functions:
91
94
92
95
Now run `faas-cli up`
93
96
94
-
Your code will now listen on port 8080 and fulfil the serverless definition including automatic health-checks and a graceful shutdown.
97
+
Your code will now listen on port 8080 and implement the workload definition for OpenFaaS including automatic health-checks and a graceful shutdown.
95
98
96
99
You can then access the service at: `http://127.0.0.1:8080/function/node-service`
97
100
@@ -207,7 +210,6 @@ Readiness probes use the same HTTP path as the health check by default. The path
207
210
* `com.openfaas.ready.http.successThreshold`
208
211
* `com.openfaas.ready.http.failureThreshold`
209
212
210
-
211
213
For example, you may have a function that takes 30s to initialise, but then only needs to be checked every 5s after that.
0 commit comments