kubernetesserverlessopenfaas

OpenFaas' Ingress-operator doesn't rewrite path


So I'm trying to create a more REST-like api path by using OpenFaaS' ingress-operator using the following tutorial. I verified that the ingress-operator is running by using kubectl get deploy/ingress-operator -n openfaas -o wide which showed one available.

However, it does not seem to properly change the function's path. I currently have deployed the base node14 function which can be invoked normally by visiting http://gw.example.kube/function/test-fn. I also applied the following FunctionIngress:

apiVersion: openfaas.com/v1alpha2
kind: FunctionIngress
metadata:
  name: test-fn
  namespace: openfaas
spec:
  domain: example.kube
  function: test-fn
  ingressType: nginx
  path: /api/v1/test/(.*)

But visiting http://example.kube/api/v1/test results in a 404 from Nginx. I tried removing the (.*) which will serve OpenFaaS' own 404 page when revisiting the page. Both example.kube and gw.example.kube have been set in the hosts file. Restarting the cluster also did not resolve the issue.

Additional information:

$ kubectl get ingress -n openfaas
NAME                CLASS    HOSTS             ADDRESS     PORTS   AGE
openfaas-ingress    <none>   gw.example.kube   localhost   80      4h9m
test-fn             <none>   example.kube      localhost   80      34m
$ kubectl describe ingress test-fn -n openfaas
Name:             test-fn
Namespace:        openfaas
Address:          localhost
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host          Path  Backends
  ----          ----  --------
  example.kube
                /api/v1/test/(.*)   gateway:8080 (10.1.0.184:8080)
Annotations:    com.openfaas.spec:
                  {"metadata":{"name":"test-fn","namespace":"openfaas","uid":"db7c752f-f08a-403e-9ed1-ad65d616482a","resourceVersion":"14465","gen...
                kubernetes.io/ingress.class: nginx
                nginx.ingress.kubernetes.io/rewrite-target: /function/test-fn/$1
Events:
  Type    Reason          Age               From                      Message
  ----    ------          ----              ----                      -------
  Normal  AddedOrUpdated  3s (x4 over 43m)  nginx-ingress-controller  Configuration for openfaas/test-fn was added or updated

Solution

  • Apparently there is an issue with using helm to install the Nginx ingress controller onto the Docker Desktop Kubernetes cluster. This problem has been resolved by manually applying the Nginx ingress controller manifest as per https://kubernetes.github.io/ingress-nginx/deploy/#docker-desktop.