当前位置:网站首页>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边栏推荐
- I just came back from the Ali software test. I worked for Alibaba P7 in 3+1, with an annual salary of 28*15
- April 26, 2021: the length of the integer array arr is n (3 < = n < = 10^4), and each number is
- MySQL timestamp format conversion date format string
- B. Terry sequence (thinking + greed) codeforces round 665 (Div. 2)
- 构建Go命令行程序工具链
- MySQL Innodb和Myisam
- Pytorch 转置卷积
- Global and Chinese market of computer protective film 2022-2028: Research Report on technology, participants, trends, market size and share
- 【云原生 | Kubernetes篇】Kubernetes基础入门(三)
- sql 多表更新数据非常慢
猜你喜欢

Most common usage of vim editor

Wechat official account debugging and natapp environment building
![[interview high frequency questions] sequential DP questions with difficulty of 3/5 and direct construction](/img/32/720ffa63a90cd5d37460face3fde38.png)
[interview high frequency questions] sequential DP questions with difficulty of 3/5 and direct construction

B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)

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

【应用推荐】最近大火的Apifox & Apipost 上手体验与选型建议

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

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

The equipment is connected to the easycvr platform through the national standard gb28181. How to solve the problem of disconnection?

【附下载】汉化版Awvs安装与简单使用
随机推荐
Understanding openstack network
Summer Challenge harmonyos - to do list with date effect
Rush for IPO, Hello, I'm in a hurry
微信公众号调试与Natapp环境搭建
Istio FAQ: return 426 status code
leetcode 139. Word Break 單詞拆分(中等)
2021-04-29: given an array arr, it represents a row of balloons with scores. One for each blow
一文详解JackSon配置信息
Advanced programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization
存在安全隐患 部分冒险家混动版将召回
实现领域驱动设计 - 使用ABP框架 - 领域逻辑 & 应用逻辑
The decline of China's product managers: starting from the nostalgia for jobs
April 30, 2021: there are residential areas on a straight line, and the post office can only be built on residential areas. Given an ordered positive array arr
对深度可分离卷积、分组卷积、扩张卷积、转置卷积(反卷积)的理解
用 Oasis 开发一个跳一跳(一)—— 场景搭建
2021-04-18: given a two-dimensional array matrix, the value in it is either 1 or 0,
Summary of common tools and usage
Here comes Wi Fi 7. How strong is it?
使用阿里云RDS for SQL Server性能洞察优化数据库负载-初识性能洞察
C. K-th Not Divisible by n(数学+思维) Codeforces Round #640 (Div. 4)