我通过这个例子创建了一个入口:
$ 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: /
无法提供的复杂重写呢?
1条答案
按热度按时间kwvwclae1#
OpenShift路由器不是基于nginx的,因此nginx的注解/规则不会做任何事情。如果内置的基于HAProxy的功能不能满足您的需求,您必须在应用程序级别处理install an nginx based ingress controller或重写。