当前位置:网站首页>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边栏推荐
- Several characteristics of pharmaceutical industry
- ZOJ - 4104 sequence in the pocket
- 国泰君安期货安全么?期货开户怎么开?期货手续费怎么降低?
- Pytorch transpose convolution
- Global and Chinese markets of natural insect repellents 2022-2028: Research Report on technology, participants, trends, market size and share
- Understanding of deep separable convolution, block convolution, extended convolution, transposed convolution (deconvolution)
- [cloud native | kubernetes chapter] Introduction to kubernetes Foundation (III)
- Some experiences of project K several operations in the global template
- Most common usage of vim editor
- How to easily realize online karaoke room and sing "mountain sea" with Wang Xinling
猜你喜欢

构建Go命令行程序工具链

The catch-up of domestic chips has scared Qualcomm, the leader of mobile phone chips in the United States, and made moves to cope with the competition

Cap: multiple attention mechanism, interesting fine-grained classification scheme | AAAI 2021

C. Three displays codeforces round 485 (Div. 2)

ZOJ——4104 Sequence in the Pocket(思维问题)

I just came back from the Ali software test. I worked for Alibaba P7 in 3+1, with an annual salary of 28*15

One article explains Jackson configuration information in detail
![[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
![[my advanced OpenGL learning journey] learning notes of OpenGL coordinate system](/img/21/48802245fea2921fd5e4a9a2d9ad18.jpg)
[my advanced OpenGL learning journey] learning notes of OpenGL coordinate system

日志记录真没你想的那么简单
随机推荐
C. Three displays codeforces round 485 (Div. 2)
Installer la Bibliothèque imagemagick 7.1 et l'extension imagick de PHP
使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
One article explains Jackson configuration information in detail
What is a framework?
Where is the most formal and safe account opening for speculation futures? How to open a futures account?
Efficient tools commonly used by individuals
Several characteristics of pharmaceutical industry
C. Three displays(动态规划)Codeforces Round #485 (Div. 2)
One article explains Jackson configuration information in detail
April 23, 2021: there are n cities in the TSP problem, and there is a distance between any two cities
[interview high frequency questions] sequential DP questions with difficulty of 3/5 and direct construction
Cap: multiple attention mechanism, interesting fine-grained classification scheme | AAAI 2021
Global and Chinese markets of natural insect repellents 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of Leyte coin exchange 2022-2028: Research Report on technology, participants, trends, market size and share
Pytorch transpose convolution
D. Solve the maze (thinking +bfs) codeforces round 648 (Div. 2)
Linux record -4.22 MySQL 5.37 installation (supplementary)
转置卷积详解
山金期货安全么?期货开户都是哪些流程?期货手续费怎么降低?