当前位置:网站首页>Istio FAQ: virtualservice route matching sequence
Istio FAQ: virtualservice route matching sequence
2022-06-24 16:15:00 【imroc】
This article comes from Istio Learning notes
background
Writing VirtualService When routing rules , Usually match Various paths forward to different back-end services , Sometimes names conflict accidentally , As a result, only the previous services are always matched , such as :
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test
spec:
gateways:
- default/example-gw
hosts:
- 'test.example.com'
http:
- match:
- uri:
prefix: /usrv
rewrite:
uri: /
route:
- destination:
host: usrv.default.svc.cluster.local
port:
number: 80
- match:
- uri:
prefix: /usrv-expand
rewrite:
uri: /
route:
- destination:
host: usrv-expand.default.svc.cluster.local
port:
number: 80istio Matching is matching in order , Unlike nginx Then use the longest prefix to match . Use here prefix Match , The first is /usrv, Indicates that as long as the access path prefix contains /usrv It will be forwarded to the first service , Due to the second matching path /usrv-expand It also belongs to the belt /usrv The prefix of , Therefore, it will never be forwarded to the service with the second matching path .
Solution
In this case, you can adjust the matching order , If the prefix has a conflicting relationship with inclusion , The longer it is placed in front of it :
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test
spec:
gateways:
- default/example-gw
hosts:
- 'test.example.com'
http:
- match:
- uri:
prefix: /usrv-expand
rewrite:
uri: /
route:
- destination:
host: usrv-expand.default.svc.cluster.local
port:
number: 80
- match:
- uri:
prefix: /usrv
rewrite:
uri: /
route:
- destination:
host: usrv.default.svc.cluster.local
port:
number: 80You can also use regular matching :
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test
spec:
gateways:
- default/gateway
hosts:
- 'test.example.com'
http:
- match:
- uri:
regex: "/usrv(/.*)?"
rewrite:
uri: /
route:
- destination:
host: nginx.default.svc.cluster.local
port:
number: 80
subset: v1
- match:
- uri:
regex: "/usrv-expand(/.*)?"
rewrite:
uri: /
route:
- destination:
host: nginx.default.svc.cluster.local
port:
number: 80
subset: v2边栏推荐
- Summary of common tools and usage
- leetcode 139. Word Break 單詞拆分(中等)
- Three solutions for Jenkins image failing to update plug-in Center
- Most common usage of vim editor
- The equipment is connected to the easycvr platform through the national standard gb28181. How to solve the problem of disconnection?
- D. Solve The Maze(思维+bfs)Codeforces Round #648 (Div. 2)
- 【应用推荐】最近大火的Apifox & Apipost 上手体验与选型建议
- 【附下载】汉化版Awvs安装与简单使用
- 用 Oasis 开发一个跳一跳(一)—— 场景搭建
- 【面试高频题】难度 3/5,可直接构造的序列 DP 题
猜你喜欢

Implement Domain Driven Design - use ABP framework - domain logic & application logic
![[application recommendation] the hands-on experience and model selection suggestions of apifox & apipost in the recent fire](/img/dd/24df91a8a1cf1f1b9ac635abd6863a.png)
[application recommendation] the hands-on experience and model selection suggestions of apifox & apipost in the recent fire

【面试高频题】难度 3/5,可直接构造的序列 DP 题

Remote connection raspberry pie in VNC Viewer Mode

Solution to the problem that FreeRTOS does not execute new tasks
![[cloud native | kubernetes chapter] Introduction to kubernetes Foundation (III)](/img/21/503ed54a2fa14fbfd67f75a55ec286.png)
[cloud native | kubernetes chapter] Introduction to kubernetes Foundation (III)

How to expand disk space on AWS host

CAP:多重注意力机制,有趣的细粒度分类方案 | AAAI 2021

【应用推荐】最近大火的Apifox & Apipost 上手体验与选型建议
MySQL進階系列:鎖-InnoDB中鎖的情况
随机推荐
2021-05-03: given a non negative integer num, how to avoid circular statements,
Find out the invisible assets -- use hosts collision to break through the boundary
Golang+redis reentrant lock
How does the effective date of SAP PP ECM affect the work order?
Summer Challenge harmonyos - to do list with date effect
Global and Chinese markets of natural insect repellents 2022-2028: Research Report on technology, participants, trends, market size and share
Why is it easy for enterprises to fail in implementing WMS warehouse management system
Flink Kubernetes Application部署
B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)
ThinkPHP 漏洞利用工具
How to expand disk space on AWS host
Fastjson 漏洞利用技巧
期货怎么开户安全些?哪些期货公司靠谱些?
leetcode 139. Word Break 單詞拆分(中等)
Still worried about missing measurements? Let's use Jacobo to calculate the code coverage
Transpose convolution learning notes
嵌入式开发基础之线程间通信
D. Solve the maze (thinking +bfs) codeforces round 648 (Div. 2)
April 23, 2021: there are n cities in the TSP problem, and there is a distance between any two cities
Inter thread communication of embedded development foundation