kubernetes - 带有 Header 的 Istio HTTPMatchRequest 不起作用
问题描述
似乎我的标头匹配被完全忽略了,或者标头在到达使用我的虚拟服务规则对其进行评估的点之前被修改。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-route-rules
spec:
hosts:
- mysite.com
- api.mysite.com
gateways:
- istio-system/web-gateway
- istio-system/api-gateway
http:
- match:
- headers:
Host:
exact: mysite.com
route:
- destination:
host: web.default.svc.cluster.local
port:
number: 9000
- match:
- headers:
Host:
exact: api.mysite.com
route:
- destination:
host: api.default.svc.cluster.local
port:
number: 7000
match
如果我使用以下规则,我发现路由适用于我的两个服务之一(即使我在单个 下组合时也完全忽略我的标题规则):
...
spec:
http:
- match:
- uri:
prefix: "/"
...
我认为这表现为“包罗万象”;绝对不是我想要的行为。
尽管一遍又一遍地阅读相关文档,但我担心我严重误解了 Istio 的路由概念)。请帮我弄清楚这里发生了什么。
解决方案
您可以尝试使用特定子集设置DestinationRule 。
您将必须创建一个
kind: DestinationRule
VirtualService
而不是用类似的例子来调整你的:
route:
- destination:
host:
subset: v2
- route:
- destination:
host:
subset: v1
还要记住遵循这些要求,因为在那里很容易出错。
请让我知道这是否有帮助。
推荐阅读
- gpu - 没有任何进程的 GCE 上 100% 的 GPU 利用率
- php - 在 PHP 页面上使用带有 CURL 的 OAUTH API
- node.js - TypeError:无法读取未定义的属性“drop”
- javascript - 调用 VueLoaderPlugin() 会导致“findIndex”未定义错误
- c++ - 使用 SWI-cpp.h 创建一个列表
- php - 使用 PHP Simple HTML DOM Parser 从表中获取数据
- python - 如何通过引用已经排序的列表最好地在 Python 列表中插入 NaN 值
- class - 如何定义一个唯一的角色是执行一个动作的类
- php - 使用 zf-hal 水合器失败
- sql - MSSQL 从分组结果中选择最大值