因此,我尝试使用下面的tutorial使用OpenFaaS的入口操作符来创建一个更像REST的api路径。我使用kubectl get deploy/ingress-operator -n openfaas -o wide验证了入口操作符是否正在运行,它显示了一个可用的入口操作符。
但是,它似乎没有正确地更改函数的路径。我目前已经部署了可以通过访问http://gw.example.kube/function/test-fn正常调用的基本node14函数。我还应用了以下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/(.*)但访问http://example.kube/api/v1/test的结果是来自Nginx的404。我尝试删除(.*),它将在重新访问OpenFaaS自己的404页面时为该页面提供服务。已在主机文件中设置了example.kube和gw.example.kube。重新启动群集也不能解决问题。
其他信息:
$ 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发布于 2021-07-25 22:52:59
显然,使用helm将Nginx入口控制器安装到Docker Desktop Kubernetes集群上存在问题。已通过根据https://kubernetes.github.io/ingress-nginx/deploy/#docker-desktop手动应用Nginx入口控制器清单解决此问题。
https://stackoverflow.com/questions/68143474
复制相似问题