Skip to content

Commit 6dc052a

Browse files
committed
Update notes on workloads
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 178a2d6 commit 6dc052a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

docs/reference/workloads.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ All workloads must:
99
* serve HTTP traffic on TCP port 8080
1010
* assume ephemeral storage
1111
* be stateless
12+
* have a name of no more than 63 characters
1213

1314
And integrate with a health-check mechanism with Kubernetes:
1415

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
1718

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)
1920

2021
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.
2122

@@ -39,9 +40,11 @@ Custom binaries can also be used as a function. Just use the `dockerfile` langua
3940

4041
### Running an existing Docker image on OpenFaaS
4142

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

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`
4548

4649
Start by creating a new folder:
4750

@@ -53,10 +56,10 @@ Write a custom Dockerfile `./node-service/Dockerfile`:
5356

5457
```Dockerfile
5558
# Import the OpenFaaS of-watchdog
56-
FROM openfaas/of-watchdog:0.7.2 as watchdog
59+
FROM ghcr.io/openfaas/of-watchdog:0.9.16 as watchdog
5760

5861
# Add a FROM line from your existing image
59-
FROM alexellis2/service:0.3.6
62+
FROM alexellis2/service:0.4.1
6063

6164
# Let's say that the image listens on port 3000 and
6265
# that we can't change that easily
@@ -91,7 +94,7 @@ functions:
9194
9295
Now run `faas-cli up`
9396

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

9699
You can then access the service at: `http://127.0.0.1:8080/function/node-service`
97100

@@ -207,7 +210,6 @@ Readiness probes use the same HTTP path as the health check by default. The path
207210
* `com.openfaas.ready.http.successThreshold`
208211
* `com.openfaas.ready.http.failureThreshold`
209212

210-
211213
For example, you may have a function that takes 30s to initialise, but then only needs to be checked every 5s after that.
212214

213215
```yaml

0 commit comments

Comments
 (0)