-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVirtualService.yaml
46 lines (45 loc) · 2.57 KB
/
VirtualService.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews-route
spec:
hosts: # 必要字段:流量的目标主机。
- reviews.prod.svc.cluster.local
gateways: # Gateway 名称列表,默认是mesh,指代网格中的所有 Sidecar
- mesh
http:
- match:
- uri:
prefix: "/wpcatalog"
- uri:
prefix: "/consumercatalog"
rewrite:
uri: "/newcatalog"
route: # 同下
- destination:
host: reviews.prod.svc.cluster.local
subset: v2
- route: # HTTP 规则对流量可能进行重定向或者转发(缺省),
- destination:
host: reviews.prod.svc.cluster.local # 目标服务的名称
subset: v1 # 服务子集的名称。仅对网格中的服务有效。必须在 DestinationRule 中定义子集。
weight: 100 # 转发给一个服务版本的流量占总流量的百分比。几个目标的百分比之和必须等于 100。
timeout: 30s # HTTP 请求的超时设置。
retries:
attempts: 3 # 为特定请求设置重试次数。重试之间的间隔是自动决定的(最少 25 毫秒)。实际重试次数还受路由规则中 timeout 设置的限制。
perTryTimeout: 2s # 每次重试的超时时间。
fault: # 应用到 HTTP 请求客户端的故障注入策略。注意:客户端启用了故障注入之后,超时和重试会被忽略。
abort:
percent: 10 # 用来指定中断请求的比例。如果没有指定 percent,则中断所有请求。
httpStatus: 400 # 用来定义返回给客户端服务的有效的 HTTP 错误代码。
delay:
percent: 10 # 用来指定注入延迟的比例。如果没有指定 percent,为所有请求进行延迟注入。
fixedDelay: 5s # 在请求转发之前加入的固定延迟。
# mirror: # 在把 HTTP 请求转发给预期目标的同时,对流量进行镜像并发送给其他目标。
# corsPolicy: # 跨来源资源共享
# appendHeaders: # 在向目标服务转发请求之前,加入额外的 HTTP Header
# redirect: #302跳转, 见: https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#HTTPRedirect
# rewrite: #rewrite, 见: https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#HTTPRewrite
# tls: #见: https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#TLSMatchAttributes
# tcp: #见: https://istio.io/docs/reference/config/networking/v1alpha3/virtual-service/#TCPRoute
# exportTo: * # 作用范围,".": 当前空间, "*":所有空间,默认所有空间