Istio从入门到精通—— 流量治理的原理 —— VirutalService —— HTTPRoute

流量治理的原理 —— VirutalService —— HTTPRoute

https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRoute

  Describes match conditions and actions for routing HTTP/1.1, HTTP2, and gRPC traffic. See VirtualService for usage examples.

描述了用于路由 HTTP/1.1、HTTP2 和 gRPC 流量的匹配条件和操作。有关使用示例,请参阅 VirtualService。

Field Type Description Required
name string

The name assigned to the route for debugging purposes. The route’s name will be concatenated with the match’s name and will be logged in the access logs for requests matching this route/match.

为了调试目的而分配给路由的名称。路由的名称将与匹配的名称连接起来,并将记录在访问日志中,以匹配此路由/匹配的请求。

我的理解是:Istio 中 HTTPRoute 的一个属性:name。这个 name 属性主要用于调试目的。当请求匹配到这个 HTTPRoute 时,这个 HTTPRoute 的 name 会与匹配的名称(match's name)进行连接(concatenate),然后这个连接后的名称会被记录在访问日志(access logs)中。

在Istio服务网格中,HTTPRoute 规则被用于定义 HTTP 请求的路由行为。例如,可以根据 HTTP 请求的路径、头部信息等来定义不同的路由规则,以实现请求的路由、负载均衡、熔断等功能。在这个过程中,给 HTTPRoute 规则定义一个name,可以帮助我们更好地理解和追踪请求的处理过程。

No
match HTTPMatchRequest[]

Match conditions to be satisfied for the rule to be activated. All conditions inside a single match block have AND semantics, while the list of match blocks have OR semantics. The rule is matched if any one of the match blocks succeed.

为激活规则而满足的匹配条件。单个匹配块中的所有条件都具有 AND 语义,而匹配块的列表具有 OR 语义。如果任何一个匹配块成功,则匹配规则。

No
route HTTPRouteDestination[]

A HTTP rule can either return a direct_response, redirect or forward (default) traffic. The forwarding target can be one of several versions of a service (see glossary in beginning of document). Weights associated with the service version determine the proportion of traffic it receives.

HTTP 规则可以返回直接响应、重定向或转发(默认)流量。转发目标可以是服务的几个版本之一(请参阅本文档开头的术语表)。与服务版本关联的权重决定了它接收的流量比例。

No
redirect HTTPRedirect

A HTTP rule can either return a direct_response, redirect or forward (default) traffic. If traffic passthrough option is specified in the rule, route/redirect will be ignored. The redirect primitive can be used to send a HTTP 301 redirect to a different URI or Authority.

HTTP规则可以返回直接响应、重定向或转发(默认)流量。如果在规则中指定了流量透传选项,则路由/重定向将被忽略。重定向原语可用于发送HTTP 301重定向到不同的URI或权威。

No
directResponse HTTPDirectResponse

A HTTP rule can either return a direct_response, redirect or forward (default) traffic. Direct Response is used to specify a fixed response that should be sent to clients.

HTTP 规则可以返回 direct _ response、 redirect 或 forward (默认)流量。Direct Response 用于指定应发送给客户端的固定响应。只有当 Route 和 Redirect 为空时才能设置它。

It can be set only when Route and Redirect are empty.

只有当 Route 和 Redirect 为空时才能设置它。

No
delegate(代理 [ˈdεləˌget] ) Delegate

Delegate is used to specify the particular VirtualService which can be used to define delegate HTTPRoute.

Delegate 用于指定特定的 VirtualService,可以用于定义代理的 HTTPRoute。

It can be set only when Route and Redirect are empty, and the route rules of the delegate VirtualService will be merged with that in the current one.

它只能在 Route 和 Redirect 为空时设置,并且委托 VirtualService 的路由规则将与当前路由规则合并。

NOTE:

  1. Only one level delegation is supported.
  2. 只支持一级代理。

  3. The delegate’s HTTPMatchRequest must be a strict subset of the root’s, otherwise there is a conflict and the HTTPRoute will not take effect.
  4. 代理的 HTTPMatchRequest 必须是根的严格子集,否则存在冲突,HTTPRoute 将无效。

No
rewrite HTTPRewrite

Rewrite HTTP URIs and Authority headers. Rewrite cannot be used with Redirect primitive. Rewrite will be performed before forwarding.

重写 HTTP URI 和权威性 headers。重写不能与重定向原始指令一起使用。重写将在转发之前执行。

No
timeout Duration

Timeout for HTTP requests, default is disabled.

No
retries HTTPRetry

Retry policy for HTTP requests.

No
fault HTTPFaultInjection

Fault injection policy to apply on HTTP traffic at the client side. Note that timeouts or retries will not be enabled when faults are enabled on the client side.

在客户端 HTTP 流量上应用故障注入策略。请注意,当在客户端启用故障时,将不会启用超时或重试。

No
mirror Destination

Mirror HTTP traffic to a another destination in addition to forwarding the requests to the intended destination. Mirrored traffic is on a best effort basis where the sidecar/gateway will not wait for the mirrored cluster to respond before returning the response from the original destination. Statistics will be generated for the mirrored destination.

除了将请求转发到预期的目的地之外,还将 HTTP 流量镜像到另一个目的地。镜像的流量以最大努力为基础,其中 sidecar/gateway 不会等待镜像集群响应,而直接返回原始目的地的响应。将会为镜像的目的地生成统计信息。

No
mirrors HTTPMirrorPolicy[]

Specifies the destinations to mirror HTTP traffic in addition to the original destination. Mirrored traffic is on a best effort basis where the sidecar/gateway will not wait for the mirrored destinations to respond before returning the response from the original destination. Statistics will be generated for the mirrored destination.

指定除原始目标之外要镜像HTTP流量的目标。镜像流量是尽力而为的,在此过程中,sidecar/gateway不会等待镜像目标响应,而是直接返回原始目标的响应。将为镜像目标生成统计信息。

No
mirrorPercentage Percent

Percentage of the traffic to be mirrored by the mirror field. If this field is absent, all the traffic (100%) will be mirrored. Max value is 100.

镜像字段要镜像的流量百分比。如果此字段不存在,所有流量(100%)都将被镜像。最大值为100。

No
corsPolicy CorsPolicy

Cross-Origin Resource Sharing policy (CORS). Refer to CORS for further details about cross origin resource sharing.

跨源资源共享策略(CORS)。有关跨源资源共享的更多详细信息,请参考CORS。

No
headers Headers

Header manipulation rules

Header 操作规则

我理解的是:在HTTP请求或响应中,对 header 字段进行修改或控制的一组规则。 "Header manipulation" 通常指的是对 HTTP headers 的修改或控制,这可能包括添加、删除、修改或根据特定条件设置某些 header 字段。这种操作可以通过手动进行,也可以通过使用编程语言或脚本自动完成。

No
posted @ 2023-12-11 15:05  左扬  阅读(49)  评论(0编辑  收藏  举报
levels of contents