networking - Istio 虚拟服务匹配 uri 和 cookie 不起作用
问题描述
我一直在尝试将此虚拟服务 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
使用上面的代码块,在 curl 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
解决方案
您好问题是老问题但仍然是实际的,所以这里的解决方案:问题来自正则表达式,第一个块;
不是可选的。
这里是更正的正则表达式。
"^(.*;?)?(user=joe)(;.*)?"
完整的细节在这里:https ://regex101.com/r/CPv2kU/3
推荐阅读
- php - 如果 php 和 jQuery 选中或未选中,则在 php 中动态创建复选框值
- html - 当我打印带有背景图像的 HTML 页面时,没有显示文本
- javascript - D3.js 在决策树中绘制菱形和连接链接
- javascript - 将javascript函数输出分配给液体变量
- image - 第一次打开或清除所有数据时,React Native 应用程序加载 url 图像很慢
- python - 使用 spacy 自定义标记器时 ReversibleField 失败
- python - 我尝试使用 pip 安装 win32gui,但出现此错误。我正在使用 python 3.8.5,我也有最新版本的 pip
- c# - 在已排序的 5 GB 文件中快速搜索行
- python - 根据另一个数字给出一个数字的最短表达式的算法
- python - TypeError:添加的层必须是类Layer的实例。成立: