Istio虚拟服务匹配uri和cookie不起作用

时间:2019-04-25 07:24:43

标签: networking kubernetes microservices istio

我一直在尝试为我的微服务应用此虚拟服务Yaml:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nameko-notifyms
spec:
  hosts:
  - "*"
  gateways:
  - nameko-notifyms-gateway
  http:
  - match:
    - headers:
        cookie:
          regex: "^(.*?;)?(user=joe)(;.*)?"
      uri:
        exact: /hello
    route:
    - destination:
        host: nameko-notifyms
        port:
          number: 8000

使用上面的代码块对uri进行卷曲之后,就不会再有流量进入pod了。

如果我将信息注释掉,如下面的代码块所示:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nameko-notifyms
spec:
  hosts:
  - "*"
  gateways:
  - nameko-notifyms-gateway
  http:
  - match:
#    - headers:
#        cookie:
#          regex: "^(.*?;)?(user=joe)(;.*)?"
    - uri:
        exact: /hello
    route:
    - destination:
        host: nameko-notifyms
        port:
          number: 8000

交通被引导到吊舱,可以在下图中显示: enter image description here

邮递员设置如下: enter image description here

1 个答案:

答案 0 :(得分:0)

您好,问题很旧,但仍然很实际,因此这里的解决方法是: 问题来自正则表达式,第一个块;不是可选的。

这里是更正的正则表达式。

"^(.*;?)?(user=joe)(;.*)?"

详细信息:https://regex101.com/r/CPv2kU/3

相关问题