Skip to content

Commit d510aee

Browse files
committed
Add REST mapping
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 3e4ec60 commit d510aee

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/reference/ssl/kubernetes-with-cert-manager.md

+76
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ We will split this tutorial into two parts:
1212

1313
- 1.0 TLS for the Gateway
1414
- 2.0 TLS and custom domains for your functions
15+
- 3.0 REST-style API mapping for your functions
1516

1617
## 1.0 TLS for the Gateway
1718

@@ -380,6 +381,81 @@ spec:
380381
ingressType: "skipper"
381382
```
382383
384+
## 3.0 REST-style API mapping for your functions
385+
386+
The FunctionIngress discussed above provides a simple way to create a custom URL mapping scheme for your functions. This is a common request from users, and means that you can map your functions into a REST-style API.
387+
388+
389+
Here we map three functions to a REST-style API:
390+
391+
```
392+
https://gateway.example.com/function/env -> https://api.example.com/v1/env/
393+
https://gateway.example.com/nodeinfo -> https://api.example.com/v1/nodeinfo/
394+
https://gateway.example.com/certinfo -> https://api.example.com/v1/certinfo/
395+
```
396+
397+
```
398+
faas-cli deploy --image functions/alpine:latest --name env --fprocess env
399+
faas-cli store deploy nodeinfo
400+
faas-cli store deploy certinfo
401+
```
402+
403+
Save the following in a file "fni.yaml" and customise it as required.
404+
405+
Then run `kubectl apply -f fni.yaml`.
406+
407+
To create the TLS Issuer, see the steps above.
408+
409+
```yaml
410+
apiVersion: openfaas.com/v1alpha2
411+
kind: FunctionIngress
412+
metadata:
413+
name: nodeinfo
414+
namespace: openfaas
415+
spec:
416+
domain: "api.example.com"
417+
function: "nodeinfo"
418+
ingressType: "nginx"
419+
path: "/v1/nodeinfo/(.*)"
420+
tls:
421+
enabled: true
422+
issuerRef:
423+
name: "letsencrypt-staging"
424+
kind: "Issuer"
425+
---
426+
apiVersion: openfaas.com/v1alpha2
427+
kind: FunctionIngress
428+
metadata:
429+
name: env
430+
namespace: openfaas
431+
spec:
432+
domain: "api.example.com"
433+
function: "env"
434+
ingressType: "nginx"
435+
path: "/v1/env/(.*)"
436+
tls:
437+
enabled: true
438+
issuerRef:
439+
name: "letsencrypt-staging"
440+
kind: "Issuer"
441+
---
442+
apiVersion: openfaas.com/v1alpha2
443+
kind: FunctionIngress
444+
metadata:
445+
name: certinfo
446+
namespace: openfaas
447+
spec:
448+
domain: "api.example.com"
449+
function: "certinfo"
450+
ingressType: "nginx"
451+
path: "/v1/certinfo/(.*)"
452+
tls:
453+
enabled: true
454+
issuerRef:
455+
name: "letsencrypt-staging"
456+
kind: "Issuer"
457+
```
458+
383459
#### What about IngressController X?
384460
385461
Feel free to raise a feature request for your IngressController on the [GitHub repo](https://github.com/openfaas-incubator/ingress-operator).

0 commit comments

Comments
 (0)