我试图通过istio入口路由我的微服务,配置如下:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test
annotations:
kubernetes.io/ingress.class: "istio"
spec:
rules:
- http:
paths:
- path: /internal/v1.0/service
backend:
serviceName: sleep
servicePort: 80
- path: /external/v1.0/service
backend:
serviceName: sleep
servicePort: 80
当我测试这个配置时,从集群得到404响应。
看来istio威胁到了我作为正则表达式的路径
â istioctl -n istio-shop get ingress-rule test-1-1
destination: sleep.istio-shop.svc.cluster.local
match:
httpHeaders:
uri:
regex: /internal/v1.0/service
route:
- tags:
servicePortNum: "80"
tlsSecret: ""
我找到的唯一解决办法就是摆脱”在服务API版本中,并使用以下内容:
- path: /internal/v1/service
结果:
â istioctl -n istio-shop get ingress-rule test-1-3
destination: sleep.istio-shop.svc.cluster.local
match:
httpHeaders:
uri:
exact: /external/v1/service
route:
- tags:
servicePortNum: "80"
tlsSecret: ""
和
- path: /internal/v1.*
结果:
â istioctl -n istio-shop get ingress-rule test-1-4
destination: sleep.istio-shop.svc.cluster.local
match:
httpHeaders:
uri:
prefix: /external/v1
route:
- tags:
servicePortNum: "80"
tlsSecret: ""
我猜是“点”作为正则表达式部分处理,而不是常规符号。
这是一个bug吗?因为“/internal/v1.0/service”不是正则表达式