kubernetes 为什么入口重写在openshift中不起作用?

nkkqxpd9  于 2022-11-21  发布在  Kubernetes
关注(0)|答案(1)|浏览(141)

我通过这个例子创建了一个入口:

$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
spec:
  ingressClassName: nginx
  rules:
  - host: my.hostname.com
    http:
      paths:
      - path: /something(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: http-svc
            port: 
              number: 80
' | kubectl create -f -

但如果转到my.hostname.com/something,则路径不匹配,即使我将其更改为

$ echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: rewrite
spec:
  ingressClassName: nginx
  rules:
  - host: my.hostname.com
    http:
      paths:
      - path: /something
        pathType: Prefix
        backend:
          service:
            name: http-svc
            port: 
              number: 80
' | kubectl create -f -

路由将我传递到http-svc,但rewrite不工作。
那么,如何才能进行haproxy.router.openshift.io/rewrite-target: /无法提供的复杂重写呢?

kwvwclae

kwvwclae1#

OpenShift路由器不是基于nginx的,因此nginx的注解/规则不会做任何事情。如果内置的基于HAProxy的功能不能满足您的需求,您必须在应用程序级别处理install an nginx based ingress controller或重写。

相关问题