当前位置:网站首页>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边栏推荐
- There are potential safety hazards Land Rover recalls some hybrid vehicles
- Golang+redis distributed mutex
- 国泰君安期货安全么?期货开户怎么开?期货手续费怎么降低?
- Global and Chinese market of insect proof clothing 2022-2028: Research Report on technology, participants, trends, market size and share
- Is Shanjin futures safe? What are the procedures for opening futures accounts? How to reduce the futures commission?
- Solution of intelligent all in one machine in expressway service area
- Istio FAQ: region awareness does not take effect
- The penetration of 5g users of operators is far slower than that of 4G. The popularity of 5g still depends on China Radio and television
- [download attached] installation and simple use of Chinese version of awvs
- B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)
猜你喜欢

How to easily realize online karaoke room and sing "mountain sea" with Wang Xinling

Linux record -4.22 MySQL 5.37 installation (supplementary)

微信公众号调试与Natapp环境搭建

存在安全隐患 部分冒险家混动版将召回

60 个神级 VS Code 插件!!

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

Solution of intelligent all in one machine in expressway service area

用 Oasis 开发一个跳一跳(一)—— 场景搭建

B. Terry sequence (thinking + greed) codeforces round 665 (Div. 2)

Three solutions for Jenkins image failing to update plug-in Center
随机推荐
A new weapon to break the memory wall has become a "hot search" in the industry! Persistent memory enables workers to play with massive data + high-dimensional models
Global and Chinese market of insect proof clothing 2022-2028: Research Report on technology, participants, trends, market size and share
转置卷积详解
Several common DoS attacks
MD5 verification based on stm32
Istio FAQ: return 426 status code
Pytorch transpose convolution
日志记录真没你想的那么简单
对深度可分离卷积、分组卷积、扩张卷积、转置卷积(反卷积)的理解
What is a framework?
How to easily realize online karaoke room and sing "mountain sea" with Wang Xinling
[download attached] installation and simple use of Chinese version of awvs
Some experiences of project K several operations in the global template
The decline of China's product managers: starting from the nostalgia for jobs
转置卷积学习笔记
ZOJ——4104 Sequence in the Pocket(思维问题)
使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
存在安全隐患 部分冒险家混动版将召回
One article explains Jackson configuration information in detail
mysql时间戳格式转换日期格式字符串