簡體   English   中英

Istio 虛擬服務匹配 uri 和 cookie 不工作

[英]Istio Virtual Service match uri and cookie not working

我一直在嘗試為我的微服務應用這個虛擬服務 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

流量被引導到 pod,如下圖所示: 在此處輸入圖像描述

郵遞員設置如下: 在此處輸入圖像描述

您好,問題是老問題但仍然存在,所以這里是解決方案:問題來自第一個塊的正則表達式; 不是可選的。

這里是更正后的正則表達式。

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

此處提供完整詳細信息: https ://regex101.com/r/CPv2kU/3

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM