Istio从入门到精通—— 流量治理的原理 —— VirutalService —— HTTPRouteDestination
流量治理的原理 —— VirutalService —— HTTPRouteDestination
https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRouteDestination
Each routing rule is associated with one or more service versions (see glossary in the beginning of the document). Weights associated with the version determine the proportion of traffic it receives. For example, the following rule will route 25% of traffic for the “reviews” service to instances with the “v2” tag and the remaining traffic (i.e., 75%) to “v1”.
associated:英[əˈsəʊsieɪtɪd] 美[əˈsoʊsieɪtɪd]
释义:
adj. 相关的;(用于联合企业的名称)联合的;有关联的;有联系的;
v. 联系;联想;交往;表示同意;(尤指)混在一起;表明支持;
glossary:英[ˈɡlɒsəri] 美[ˈɡlɑːsəri]
释义:
n. 词汇表;术语汇编;
determine:英[dɪˈtɜːmɪn] 美[dɪˈtɜːrmɪn]
释义:
v.确定;测定;决定;决定,决心(做某事);影响;形成;安排;裁决;查明;支配;准确算出;
proportion:英[prəˈpɔːʃn] 美[prəˈpɔːrʃn]
释义:
n.比例;部分;面积;份额;均衡;匀称;正确的比例;倍数关系;等比关系;
v.分配;使相称;
traffic
:英[ˈtræfɪk] 美[ˈtræfɪk]
释义:
n.交通;运输;(沿固定路线的)航行,行驶,飞行;(非法的)交易,买卖;人流;信息流量;货流;路上行驶的车辆;
v.在…通行;交易;买卖;用…作交换;
route
:英[ruːt] 美[ruːt]
释义:
n.路线;途径;渠道;路途;(公共汽车和列车等的)常规路线,固定线路;(用于美国干线公路号码前);
vt.按某路线发送;
remaining
:英[rɪˈmeɪnɪŋ] 美[rɪˈmeɪnɪŋ]
释义:
adj.剩下的;仍需做的;还需处理的;
v.仍然是;剩余;保持不变;遗留;继续存在;仍需去做(或说、处理);
每条路由规则都与一个或多个服务版本相关联(请参阅本文开头的术语表)。与版本关联的权重决定了它接收的流量比例。例如,以下规则将把“reviews”服务流量的25%路由到带有“v2”标签的实例,其余流量(即75%)路由到“v1”。
我的理解是:一个路由规则如何根据不同的服务版本(如“v1”和“v2”)来分配流量。在给定的例子中,“reviews”服务的25%的流量会被路由到“v2”版本,而其余的75%则被路由到“v1”版本。
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: reviews-route spec: hosts: - reviews.prod.svc.cluster.local http: - route: - destination: host: reviews.prod.svc.cluster.local subset: v2 weight: 25 - destination: host: reviews.prod.svc.cluster.local subset: v1 weight: 75
And the associated DestinationRule
以及相关联的 DestinationRule
apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: reviews-destination spec: host: reviews.prod.svc.cluster.local subsets: - name: v1 labels: version: v1 - name: v2 labels: version: v2
Traffic can also be split across two entirely different services without having to define new subsets. For example, the following rule forwards 25% of traffic to reviews.com to dev.reviews.com
流量也可以分配到两个完全不同的服务上,无需定义新的子集。例如,以下规则将25%的流量转发到 reviews.com,然后转发到 dev.reviews.com
apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: reviews-route-two-domains spec: hosts: - reviews.com http: - route: - destination: host: dev.reviews.com weight: 25 - destination: host: reviews.com weight: 75
Field | Type | Description | Required |
destination | Destination |
Destination uniquely identifies the instances of a service to which the request/connection should be forwarded to. 目的地唯一标识请求/连接应转发到的服务实例。 |
Yes |
weigth | int32 |
Weight specifies the relative proportion of traffic to be forwarded to the destination. A destination will receive weight/(sum of all weights) requests. If there is only one destination in a rule, it will receive all traffic. Otherwise, if weight is 0, the destination will not receive any traffic. 权重指定了转发到目的地的相对流量比例。目的地将收到权重/(所有权重的总和)的请求。如果规则中只有一个目的地,它将收到所有流量。否则,如果权重为0,目的地将不会收到任何流量。 |
No |
headers | Headers |
Header manipulation rules 标题操作规则 |
No |