首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenFaas的入口运算符不重写路径

OpenFaas的入口运算符不重写路径
EN

Stack Overflow用户
提问于 2021-06-26 22:52:57
回答 1查看 71关注 0票数 0

因此,我尝试使用下面的tutorial使用OpenFaaS的入口操作符来创建一个更像REST的api路径。我使用kubectl get deploy/ingress-operator -n openfaas -o wide验证了入口操作符是否正在运行,它显示了一个可用的入口操作符。

但是,它似乎没有正确地更改函数的路径。我目前已经部署了可以通过访问http://gw.example.kube/function/test-fn正常调用的基本node14函数。我还应用了以下FunctionIngress:

代码语言:javascript
复制
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.kubegw.example.kube。重新启动群集也不能解决问题。

其他信息:

代码语言:javascript
复制
$ 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
代码语言:javascript
复制
$ 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-25 22:52:59

显然,使用helm将Nginx入口控制器安装到Docker Desktop Kubernetes集群上存在问题。已通过根据https://kubernetes.github.io/ingress-nginx/deploy/#docker-desktop手动应用Nginx入口控制器清单解决此问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68143474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档