When you expose the OpenFaaS Gateway via TLS, each function will already be accessible over TLS by adding /function/NAME to the URL.
This page is for users who want to create custom domains for individual functions, or to create a REST-like mapping for a number of functions.
It's important that you never expose a function's Pod or Deployment directly, but only via the OpenFaaS gateway. The gateway is required in the invocation path to provide metrics, auto-scaling and asynchronous invocations etc. In order to do this, you will need to create a DNS record and Ingress resource that points to the function's existing path on the gateway service.
In order to automate the process, we built the ingress-operator which has its own Custom Resource Definition (CRD) called FunctionIngress. The role of FunctionIngress is to create an Ingress Kubernetes object to map a function to a domain-name, and optionally to also provision a TLS certificate using cert-manager.
Once set up, you'll be able to access a function such as env via https://env.example.com along with the longer form of: https://gateway.example.com/function/env.
You can install the ingress-operator by passing --set ingressOperator.create=true to the Helm chart at the installation time of OpenFaaS. Or by adding the following to your values.yaml file:
ingressOperator:create:true
Run the helm upgrade --install command that you used originally to install OpenFaaS.
If you use arkade, add the --ingress-operator flag to arkade install openfaas.
Check that the operator was deployed and has started:
Any annotations that you add to the FunctionIngress will be added to the Ingress record. This is useful for adding custom annotations that your IngressController supports such as timeouts, rate-limiting or authorization settings.
FunctionIngress without TLS
The FunctionIngress makes most sense when using TLS, however you can omit TLS for testing by removing the tls section of the spec.
Deleting FunctionIngress records
You can see the FunctionIngress records via:
kubectlgetfunctioningress-nopenfaas
Then delete one if you need to via: kubectl delete functioningress/name -n openfaas.
Short name for FunctionIngress
The short name is fni i.e. kubectl get fni -n openfaas.
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.
You may wish to map different versions of functions to a top-level domain: