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

发布时间 2023-12-11 15:06:28作者: 左扬

流量治理的原理 —— 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.

FieldTypeDescriptionRequired
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.

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.

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.

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.

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.

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

No
delegate Delegate

Delegate is used to specify the particular VirtualService which can be used to define delegate 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.

NOTE:

  1. Only one level delegation is supported.
  2. 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.
No
rewrite HTTPRewrite

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

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.

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.

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.

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.

No
corsPolicy CorsPolicy

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

No
headers Headers

Header manipulation rules

No