- Virtual Service
- CorsPolicy
- Destination
- HTTPFaultInjection
- HTTPFaultInjection.Abort
- HTTPFaultInjection.Delay
- HTTPMatchRequest
- HTTPRedirect
- HTTPRetry
- HTTPRewrite
- HTTPRoute
- HTTPRouteDestination
- Headers
- Headers.HeaderOperations
- L4MatchAttributes
- Percent
- PortSelector
- RouteDestination
- StringMatch
- TCPRoute
- TLSMatchAttributes
- TLSRoute
- VirtualService
- google.protobuf.UInt32Value
Virtual Service
Configuration affecting traffic routing. Here are a few terms useful to definein the context of traffic routing.
Service
a unit of application behavior bound to a unique name in aservice registry. Services consist of multiple network _endpoints_implemented by workload instances running on pods, containers, VMs etc.
Service versions (a.k.a. subsets)
- In a continuous deploymentscenario, for a given service, there can be distinct subsets ofinstances running different variants of the application binary. Thesevariants are not necessarily different API versions. They could beiterative changes to the same service, deployed in differentenvironments (prod, staging, dev, etc.). Common scenarios where thisoccurs include A/B testing, canary rollouts, etc. The choice of aparticular version can be decided based on various criterion (headers,url, etc.) and/or by weights assigned to each version. Each service hasa default version consisting of all its instances.
Source
- A downstream client calling a service.
Host
- The address used by a client when attempting to connect to aservice.
Access model
- Applications address only the destination service(Host) without knowledge of individual service versions (subsets). Theactual choice of the version is determined by the proxy/sidecar, enabling theapplication code to decouple itself from the evolution of dependentservices.
A VirtualService
defines a set of traffic routing rules to apply when a host isaddressed. Each routing rule defines matching criteria for traffic of a specificprotocol. If the traffic is matched, then it is sent to a named destination service(or subset/version of it) defined in the registry.
The source of traffic can also be matched in a routing rule. This allows routingto be customized for specific client contexts.
The following example on Kubernetes, routes all HTTP traffic by default topods of the reviews service with label “version: v1”. In addition,HTTP requests with path starting with /wpcatalog/ or /consumercatalog/ willbe rewritten to /newcatalog and sent to pods with label “version: v2”.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews-route
spec:
hosts:
- reviews.prod.svc.cluster.local
http:
- name: "reviews-v2-routes"
match:
- uri:
prefix: "/wpcatalog"
- uri:
prefix: "/consumercatalog"
rewrite:
uri: "/newcatalog"
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v2
- name: "reviews-v1-route"
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v1
A subset/version of a route destination is identified with a referenceto a named service subset which must be declared in a correspondingDestinationRule
.
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
CorsPolicy
Describes the Cross-Origin Resource Sharing (CORS) policy, for a givenservice. Refer to CORSfor further details about cross origin resource sharing. For example,the following rule restricts cross origin requests to those originatingfrom example.com domain using HTTP POST/GET, and sets theAccess-Control-Allow-Credentials
header to false. In addition, it onlyexposes X-Foo-bar
header and sets an expiry period of 1 day.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- route:
- destination:
host: ratings.prod.svc.cluster.local
subset: v1
corsPolicy:
allowOrigin:
- example.com
allowMethods:
- POST
- GET
allowCredentials: false
allowHeaders:
- X-Foo-Bar
maxAge: "24h"
Field | Type | Description | Required |
---|---|---|---|
allowOrigin | string[] | The list of origins that are allowed to perform CORS requests. Thecontent will be serialized into the Access-Control-Allow-Originheader. Wildcard * will allow all origins. | No |
allowMethods | string[] | List of HTTP methods allowed to access the resource. The content willbe serialized into the Access-Control-Allow-Methods header. | No |
allowHeaders | string[] | List of HTTP headers that can be used when requesting theresource. Serialized to Access-Control-Allow-Headers header. | No |
exposeHeaders | string[] | A white list of HTTP headers that the browsers are allowed toaccess. Serialized into Access-Control-Expose-Headers header. | No |
maxAge | Duration | Specifies how long the results of a preflight request can becached. Translates to the Access-Control-Max-Age header. | No |
allowCredentials | BoolValue | Indicates whether the caller is allowed to send the actual request(not the preflight) using credentials. Translates to Access-Control-Allow-Credentials header. | No |
Destination
Destination indicates the network addressable service to which therequest/connection will be sent after processing a routing rule. Thedestination.host should unambiguously refer to a service in the serviceregistry. Istio’s service registry is composed of all the services foundin the platform’s service registry (e.g., Kubernetes services, Consulservices), as well as services declared through theServiceEntry resource.
Note for Kubernetes users: When short names are used (e.g. “reviews”instead of “reviews.default.svc.cluster.local”), Istio will interpretthe short name based on the namespace of the rule, not the service. Arule in the “default” namespace containing a host “reviews will beinterpreted as “reviews.default.svc.cluster.local”, irrespective of theactual namespace associated with the reviews service. To avoid potentialmisconfigurations, it is recommended to always use fully qualifieddomain names over short names.
The following Kubernetes example routes all traffic by default to podsof the reviews service with label “version: v1” (i.e., subset v1), andsome to subset v2, in a Kubernetes environment.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews-route
namespace: foo
spec:
hosts:
- reviews # interpreted as reviews.foo.svc.cluster.local
http:
- match:
- uri:
prefix: "/wpcatalog"
- uri:
prefix: "/consumercatalog"
rewrite:
uri: "/newcatalog"
route:
- destination:
host: reviews # interpreted as reviews.foo.svc.cluster.local
subset: v2
- route:
- destination:
host: reviews # interpreted as reviews.foo.svc.cluster.local
subset: v1
And the associated DestinationRule
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews-destination
namespace: foo
spec:
host: reviews # interpreted as reviews.foo.svc.cluster.local
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
The following VirtualService sets a timeout of 5s for all calls toproductpage.prod.svc.cluster.local service in Kubernetes. Notice thatthere are no subsets defined in this rule. Istio will fetch allinstances of productpage.prod.svc.cluster.local service from the serviceregistry and populate the sidecar’s load balancing pool. Also, noticethat this rule is set in the istio-system namespace but uses the fullyqualified domain name of the productpage service,productpage.prod.svc.cluster.local. Therefore the rule’s namespace doesnot have an impact in resolving the name of the productpage service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-productpage-rule
namespace: istio-system
spec:
hosts:
- productpage.prod.svc.cluster.local # ignores rule namespace
http:
- timeout: 5s
route:
- destination:
host: productpage.prod.svc.cluster.local
To control routing for traffic bound to services outside the mesh, externalservices must first be added to Istio’s internal service registry using theServiceEntry resource. VirtualServices can then be defined to control trafficbound to these external services. For example, the following rules define aService for wikipedia.org and set a timeout of 5s for http requests.
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: external-svc-wikipedia
spec:
hosts:
- wikipedia.org
location: MESH_EXTERNAL
ports:
- number: 80
name: example-http
protocol: HTTP
resolution: DNS
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: my-wiki-rule
spec:
hosts:
- wikipedia.org
http:
- timeout: 5s
route:
- destination:
host: wikipedia.org
Field | Type | Description | Required |
---|---|---|---|
host | string | The name of a service from the service registry. Servicenames are looked up from the platform’s service registry (e.g.,Kubernetes services, Consul services, etc.) and from the hostsdeclared by ServiceEntry. Traffic forwarded todestinations that are not found in either of the two, will be dropped. Note for Kubernetes users: When short names are used (e.g. “reviews”instead of “reviews.default.svc.cluster.local”), Istio will interpretthe short name based on the namespace of the rule, not the service. Arule in the “default” namespace containing a host “reviews will beinterpreted as “reviews.default.svc.cluster.local”, irrespective ofthe actual namespace associated with the reviews service. To avoidpotential misconfigurations, it is recommended to always use fullyqualified domain names over short names. | Yes |
subset | string | The name of a subset within the service. Applicable only to serviceswithin the mesh. The subset must be defined in a correspondingDestinationRule. | No |
port | PortSelector | Specifies the port on the host that is being addressed. If a serviceexposes only a single port it is not required to explicitly select theport. | No |
HTTPFaultInjection
HTTPFaultInjection can be used to specify one or more faults to injectwhile forwarding http requests to the destination specified in a route.Fault specification is part of a VirtualService rule. Faults includeaborting the Http request from downstream service, and/or delayingproxying of requests. A fault rule MUST HAVE delay or abort or both.
Note: Delay and abort faults are independent of one another, even ifboth are specified simultaneously.
Field | Type | Description | Required |
---|---|---|---|
delay | Delay | Delay requests before forwarding, emulating various failures such asnetwork issues, overloaded upstream service, etc. | No |
abort | Abort | Abort Http request attempts and return error codes back to downstreamservice, giving the impression that the upstream service is faulty. | No |
HTTPFaultInjection.Abort
Abort specification is used to prematurely abort a request with apre-specified error code. The following example will return an HTTP 400error code for 1 out of every 1000 requests to the “ratings” service “v1”.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- route:
- destination:
host: ratings.prod.svc.cluster.local
subset: v1
fault:
abort:
percentage:
value: 0.1
httpStatus: 400
The httpStatus field is used to indicate the HTTP status code toreturn to the caller. The optional percentage field can be used to onlyabort a certain percentage of requests. If not specified, all requests areaborted.
Field | Type | Description | Required |
---|---|---|---|
httpStatus | int32 (oneof) | HTTP status code to use to abort the Http request. | Yes |
percentage | Percent | Percentage of requests to be aborted with the error code provided. | No |
percent | int32 | Percentage of requests to be aborted with the error code provided (0-100).Use of integer percent value is deprecated. Use the double percentage field instead. | No |
HTTPFaultInjection.Delay
Delay specification is used to inject latency into the requestforwarding path. The following example will introduce a 5 second delayin 1 out of every 1000 requests to the “v1” version of the “reviews”service from all pods with label env: prod
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews-route
spec:
hosts:
- reviews.prod.svc.cluster.local
http:
- match:
- sourceLabels:
env: prod
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v1
fault:
delay:
percentage:
value: 0.1
fixedDelay: 5s
The fixedDelay field is used to indicate the amount of delay in seconds.The optional percentage field can be used to only delay a certainpercentage of requests. If left unspecified, all request will be delayed.
Field | Type | Description | Required |
---|---|---|---|
fixedDelay | Duration (oneof) | Add a fixed delay before forwarding the request. Format:1h/1m/1s/1ms. MUST be >=1ms. | Yes |
percentage | Percent | Percentage of requests on which the delay will be injected. | No |
percent | int32 | Percentage of requests on which the delay will be injected (0-100).Use of integer percent value is deprecated. Use the double percentage field instead. | No |
HTTPMatchRequest
HttpMatchRequest specifies a set of criterion to be met in order for therule to be applied to the HTTP request. For example, the followingrestricts the rule to match only requests where the URL pathstarts with /ratings/v2/ and the request contains a custom end-user
headerwith value jason
.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- match:
- headers:
end-user:
exact: jason
uri:
prefix: "/ratings/v2/"
ignoreUriCase: true
route:
- destination:
host: ratings.prod.svc.cluster.local
HTTPMatchRequest CANNOT be empty.
Field | Type | Description | Required |
---|---|---|---|
name | string | The name assigned to a match. The match’s name will beconcatenated with the parent route’s name and will be logged inthe access logs for requests matching this route. | No |
uri | StringMatch | URI to matchvalues are case-sensitive and formatted as follows: - exact: "value" for exact string match- prefix: "value" for prefix-based match- regex: "value" for ECMAscript style regex-based matchNote: Case-insensitive matching could be enabled via the ignoreuri_case flag. | No |
scheme | StringMatch | URI Schemevalues are case-sensitive and formatted as follows: - exact: "value" for exact string match- prefix: "value" for prefix-based match- regex: "value" for ECMAscript style regex-based match | No |
method | StringMatch | HTTP Methodvalues are case-sensitive and formatted as follows: - exact: "value" for exact string match- prefix: "value" for prefix-based match- regex: "value" for ECMAscript style regex-based match | No |
authority | StringMatch | HTTP Authorityvalues are case-sensitive and formatted as follows: - exact: "value" for exact string match- prefix: "value" for prefix-based match- regex: "value" for ECMAscript style regex-based match | No |
headers | map<string, StringMatch> | The header keys must be lowercase and use hyphen as the separator,e.g. _x-request-id. Header values are case-sensitive and formatted as follows: - exact: "value" for exact string match- prefix: "value" for prefix-based match- regex: "value" for ECMAscript style regex-based matchNote: The keys uri , scheme , method , and authority will be ignored. | No |
port | uint32 | Specifies the ports on the host that is being addressed. Many servicesonly expose a single port or label ports with the protocols they support,in these cases it is not required to explicitly select the port. | No |
sourceLabels | map<string, string> | One or more labels that constrain the applicability of a rule toworkloads with the given labels. If the VirtualService has a list ofgateways specified at the top, it must include the reserved gateway mesh for this field to be applicable. | No |
queryParams | map<string, StringMatch> | Query parameters for matching. Ex:- For a query parameter like “?key=true”, the map key would be “key” andthe string match could be defined as exact: "true" .- For a query parameter like “?key”, the map key would be “key” and thestring match could be defined as exact: "" .- For a query parameter like “?key=123”, the map key would be “key” and thestring match could be defined as regex: "\d+$" . Note that thisconfiguration will only match values like “123” but not “a123” or “123a”.Note: prefix matching is currently not supported. | No |
ignoreUriCase | bool | Flag to specify whether the URI matching should be case-insensitive. Note: The case will be ignored only in the case of exact and prefix URI matches. | No |
HTTPRedirect
HTTPRedirect can be used to send a 301 redirect response to the caller,where the Authority/Host and the URI in the response can be swapped withthe specified values. For example, the following rule redirectsrequests for /v1/getProductRatings API on the ratings service to/v1/bookRatings provided by the bookratings service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- match:
- uri:
exact: /v1/getProductRatings
redirect:
uri: /v1/bookRatings
authority: newratings.default.svc.cluster.local
...
Field | Type | Description | Required |
---|---|---|---|
uri | string | On a redirect, overwrite the Path portion of the URL with thisvalue. Note that the entire path will be replaced, irrespective of therequest URI being matched as an exact path or prefix. | No |
authority | string | On a redirect, overwrite the Authority/Host portion of the URL withthis value. | No |
redirectCode | uint32 | On a redirect, Specifies the HTTP status code to use in the redirectresponse. The default response code is MOVED_PERMANENTLY (301). | No |
HTTPRetry
Describes the retry policy to use when a HTTP request fails. Forexample, the following rule sets the maximum number of retries to 3 whencalling ratings:v1 service, with a 2s timeout per retry attempt.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- route:
- destination:
host: ratings.prod.svc.cluster.local
subset: v1
retries:
attempts: 3
perTryTimeout: 2s
retryOn: gateway-error,connect-failure,refused-stream
Field | Type | Description | Required |
---|---|---|---|
attempts | int32 | Number of retries for a given request. The intervalbetween retries will be determined automatically (25ms+). Actualnumber of retries attempted depends on the httpReqTimeout. | Yes |
perTryTimeout | Duration | Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. | No |
retryOn | string | Specifies the conditions under which retry takes place.One or more policies can be specified using a ‘,’ delimited list.See the retry policiesand gRPC retry policies for more details. | No |
HTTPRewrite
HTTPRewrite can be used to rewrite specific parts of a HTTP requestbefore forwarding the request to the destination. Rewrite primitive canbe used only with HTTPRouteDestination. The following exampledemonstrates how to rewrite the URL prefix for api call (/ratings) toratings service before making the actual API call.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ratings-route
spec:
hosts:
- ratings.prod.svc.cluster.local
http:
- match:
- uri:
prefix: /ratings
rewrite:
uri: /v1/bookRatings
route:
- destination:
host: ratings.prod.svc.cluster.local
subset: v1
Field | Type | Description | Required |
---|---|---|---|
uri | string | rewrite the path (or the prefix) portion of the URI with thisvalue. If the original URI was matched based on prefix, the valueprovided in this field will replace the corresponding matched prefix. | No |
authority | string | rewrite the Authority/Host header with this value. | No |
HTTPRoute
Describes match conditions and actions for routing HTTP/1.1, HTTP2, andgRPC traffic. See VirtualService for usage examples.
Field | Type | Description | Required |
---|---|---|---|
name | string | The name assigned to the route for debugging purposes. Theroute’s name will be concatenated with the match’s name and willbe logged in the access logs for requests matching thisroute/match. | No |
match | HTTPMatchRequest[] | Match conditions to be satisfied for the rule to beactivated. All conditions inside a single match block have ANDsemantics, while the list of match blocks have OR semantics. The ruleis matched if any one of the match blocks succeed. | No |
route | HTTPRouteDestination[] | A http rule can either redirect or forward (default) traffic. Theforwarding target can be one of several versions of a service (seeglossary in beginning of document). Weights associated with theservice version determine the proportion of traffic it receives. | No |
redirect | HTTPRedirect | A http rule can either redirect or forward (default) traffic. Iftraffic passthrough option is specified in the rule,route/redirect will be ignored. The redirect primitive can be used tosend a HTTP 301 redirect to a different URI or Authority. | No |
rewrite | HTTPRewrite | Rewrite HTTP URIs and Authority headers. Rewrite cannot be used withRedirect primitive. Rewrite will be performed before forwarding. | No |
timeout | Duration | Timeout for HTTP requests. | 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 areenabled on the client side. | No |
mirror | Destination | Mirror HTTP traffic to a another destination in addition to forwardingthe requests to the intended destination. Mirrored traffic is on abest effort basis where the sidecar/gateway will not wait for themirrored cluster to respond before returning the response from theoriginal destination. Statistics will be generated for the mirroreddestination. | No |
mirrorPercent | UInt32Value | 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 toCORSfor further details about cross origin resource sharing. | No |
headers | Headers | Header manipulation rules | No |
HTTPRouteDestination
Each routing rule is associated with one or more service versions (seeglossary in beginning of document). Weights associated with the versiondetermine the proportion of traffic it receives. For example, thefollowing rule will route 25% of traffic for the “reviews” service toinstances with the “v2” tag and the remaining traffic (i.e., 75%) to“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
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 withouthaving to define new subsets. For example, the following rule forwards 25% oftraffic to reviews.com to 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 serviceto which the request/connection should be forwarded to. | Yes |
weight | int32 | The proportion of traffic to be forwarded to the serviceversion. (0-100). Sum of weights across destinations SHOULD BE == 100.If there is only one destination in a rule, the weight value is assumed tobe 100. | No |
headers | Headers | Header manipulation rules | No |
removeResponseHeaders | string[] | Use of remove_response_header is deprecated. Use the headers field instead. | No |
appendResponseHeaders | map<string, string> | Use of append_response_headers is deprecated. Use the headers field instead. | No |
removeRequestHeaders | string[] | Use of remove_request_headers is deprecated. Use the headers field instead. | No |
appendRequestHeaders | map<string, string> | Use of append_request_headers is deprecated. Use the headers field instead. | No |
Headers
Message headers can be manipulated when Envoy forwards requests to,or responses from, a destination service. Header manipulation rules canbe specified for a specific route destination or for all destinations.The following VirtualService adds a test
header with the value true
to requests that are routed to any reviews
service destination.It also romoves the foo
response header, but only from responsescoming from the v1
subset (version) of the reviews
service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews-route
spec:
hosts:
- reviews.prod.svc.cluster.local
http:
- headers:
request:
set:
test: true
route:
- destination:
host: reviews.prod.svc.cluster.local
subset: v2
weight: 25
- destination:
host: reviews.prod.svc.cluster.local
subset: v1
headers:
response:
remove:
- foo
weight: 75
Field | Type | Description | Required |
---|---|---|---|
request | HeaderOperations | Header manipulation rules to apply before forwarding a requestto the destination service | No |
response | HeaderOperations | Header manipulation rules to apply before returning a responseto the caller | No |
Headers.HeaderOperations
HeaderOperations Describes the header manipulations to apply
Field | Type | Description | Required |
---|---|---|---|
set | map<string, string> | Overwrite the headers specified by key with the given values | No |
add | map<string, string> | Append the given values to the headers specified by keys(will create a comma-separated list of values) | No |
remove | string[] | Remove a the specified headers | No |
L4MatchAttributes
L4 connection match attributes. Note that L4 connection matching supportis incomplete.
Field | Type | Description | Required |
---|---|---|---|
destinationSubnets | string[] | IPv4 or IPv6 ip addresses of destination with optional subnet. E.g.,a.b.c.d/xx form or just a.b.c.d. | No |
port | uint32 | Specifies the port on the host that is being addressed. Many servicesonly expose a single port or label ports with the protocols they support,in these cases it is not required to explicitly select the port. | No |
sourceLabels | map<string, string> | One or more labels that constrain the applicability of a rule toworkloads with the given labels. If the VirtualService has a list ofgateways specified at the top, it should include the reserved gateway mesh in order for this field to be applicable. | No |
gateways | string[] | Names of gateways where the rule should be applied to. Gateway namesat the top of the VirtualService (if any) are overridden. The gatewaymatch is independent of sourceLabels. | No |
Percent
Percent specifies a percentage in the range of [0.0, 100.0].
Field | Type | Description | Required |
---|---|---|---|
value | double | No |
PortSelector
PortSelector specifies the number of a port to be used formatching or selection for final routing.
Field | Type | Description | Required |
---|---|---|---|
number | uint32 | Valid port number | No |
RouteDestination
L4 routing rule weighted destination.
Field | Type | Description | Required |
---|---|---|---|
destination | Destination | Destination uniquely identifies the instances of a serviceto which the request/connection should be forwarded to. | Yes |
weight | int32 | The proportion of traffic to be forwarded to the serviceversion. If there is only one destination in a rule, all traffic will berouted to it irrespective of the weight. | No |
StringMatch
Describes how to match a given string in HTTP headers. Match iscase-sensitive.
Field | Type | Description | Required |
---|---|---|---|
exact | string (oneof) | exact string match | Yes |
prefix | string (oneof) | prefix-based match | Yes |
regex | string (oneof) | ECMAscript style regex-based match | Yes |
TCPRoute
Describes match conditions and actions for routing TCP traffic. Thefollowing routing rule forwards traffic arriving at port 27017 formongo.prod.svc.cluster.local to another Mongo server on port 5555.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo-Mongo
spec:
hosts:
- mongo.prod.svc.cluster.local
tcp:
- match:
- port: 27017
route:
- destination:
host: mongo.backup.svc.cluster.local
port:
number: 5555
Field | Type | Description | Required |
---|---|---|---|
match | L4MatchAttributes[] | Match conditions to be satisfied for the rule to beactivated. All conditions inside a single match block have ANDsemantics, while the list of match blocks have OR semantics. The ruleis matched if any one of the match blocks succeed. | No |
route | RouteDestination[] | The destination to which the connection should be forwarded to. | No |
TLSMatchAttributes
TLS connection match attributes.
Field | Type | Description | Required |
---|---|---|---|
sniHosts | string[] | SNI (server name indicator) to match on. Wildcard prefixescan be used in the SNI value, e.g., *.com will match foo.example.comas well as example.com. An SNI value must be a subset (i.e., fallwithin the domain) of the corresponding virtual serivce’s hosts. | Yes |
destinationSubnets | string[] | IPv4 or IPv6 ip addresses of destination with optional subnet. E.g.,a.b.c.d/xx form or just a.b.c.d. | No |
port | uint32 | Specifies the port on the host that is being addressed. Many servicesonly expose a single port or label ports with the protocols theysupport, in these cases it is not required to explicitly select theport. | No |
sourceLabels | map<string, string> | One or more labels that constrain the applicability of a rule toworkloads with the given labels. If the VirtualService has a list ofgateways specified at the top, it should include the reserved gateway mesh in order for this field to be applicable. | No |
gateways | string[] | Names of gateways where the rule should be applied to. Gateway namesat the top of the VirtualService (if any) are overridden. The gatewaymatch is independent of sourceLabels. | No |
TLSRoute
Describes match conditions and actions for routing unterminated TLStraffic (TLS/HTTPS) The following routing rule forwards unterminated TLStraffic arriving at port 443 of gateway called “mygateway” to internalservices in the mesh based on the SNI value.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo-sni
spec:
hosts:
- "*.bookinfo.com"
gateways:
- mygateway
tls:
- match:
- port: 443
sniHosts:
- login.bookinfo.com
route:
- destination:
host: login.prod.svc.cluster.local
- match:
- port: 443
sniHosts:
- reviews.bookinfo.com
route:
- destination:
host: reviews.prod.svc.cluster.local
Field | Type | Description | Required |
---|---|---|---|
match | TLSMatchAttributes[] | Match conditions to be satisfied for the rule to beactivated. All conditions inside a single match block have ANDsemantics, while the list of match blocks have OR semantics. The ruleis matched if any one of the match blocks succeed. | Yes |
route | RouteDestination[] | The destination to which the connection should be forwarded to. | No |
VirtualService
Configuration affecting traffic routing.
Field | Type | Description | Required |
---|---|---|---|
hosts | string[] | The destination hosts to which traffic is being sent. Couldbe a DNS name with wildcard prefix or an IP address. Depending on theplatform, short-names can also be used instead of a FQDN (i.e. has nodots in the name). In such a scenario, the FQDN of the host would bederived based on the underlying platform. A single VirtualService can be used to describe all the trafficproperties of the corresponding hosts, including those for multipleHTTP and TCP ports. Alternatively, the traffic properties of a hostcan be defined using more than one VirtualService, with certaincaveats. Refer to theOperations Guidefor details. Note for Kubernetes users: When short names are used (e.g. “reviews”instead of “reviews.default.svc.cluster.local”), Istio will interpretthe short name based on the namespace of the rule, not the service. Arule in the “default” namespace containing a host “reviews” will beinterpreted as “reviews.default.svc.cluster.local”, irrespective ofthe actual namespace associated with the reviews service. To avoidpotential misconfigurations, it is recommended to always use fullyqualified domain names over short names. The hosts field applies to both HTTP and TCP services. Service insidethe mesh, i.e., those found in the service registry, must always bereferred to using their alphanumeric names. IP addresses are allowedonly for services defined via the Gateway. | Yes |
gateways | string[] | The names of gateways and sidecars that should apply these routes. Asingle VirtualService is used for sidecars inside the mesh as well asfor one or more gateways. The selection condition imposed by thisfield can be overridden using the source field in the match conditionsof protocol-specific routes. The reserved word mesh is used to implyall the sidecars in the mesh. When this field is omitted, the defaultgateway (mesh ) will be used, which would apply the rule to allsidecars in the mesh. If a list of gateway names is provided, therules will apply only to the gateways. To apply the rules to bothgateways and sidecars, specify mesh as one of the gateway names. | No |
http | HTTPRoute[] | An ordered list of route rules for HTTP traffic. HTTP routes will beapplied to platform service ports named ‘http-’/‘http2-’/‘grpc-’, gatewayports with protocol HTTP/HTTP2/GRPC/ TLS-terminated-HTTPS and serviceentry ports using HTTP/HTTP2/GRPC protocols. The first rule matchingan incoming request is used. | No |
tls | TLSRoute[] | An ordered list of route rule for non-terminated TLS & HTTPStraffic. Routing is typically performed using the SNI value presentedby the ClientHello message. TLS routes will be applied to platformservice ports named ‘https-’, ‘tls-’, unterminated gateway ports usingHTTPS/TLS protocols (i.e. with “passthrough” TLS mode) and serviceentry ports using HTTPS/TLS protocols. The first rule matching anincoming request is used. NOTE: Traffic ‘https-’ or ‘tls-’ portswithout associated virtual service will be treated as opaque TCPtraffic. | No |
tcp | TCPRoute[] | An ordered list of route rules for opaque TCP traffic. TCP routes willbe applied to any port that is not a HTTP or TLS port. The first rulematching an incoming request is used. | No |
exportTo | string[] | A list of namespaces to which this virtual service is exported. Exporting avirtual service allows it to be used by sidecars and gateways defined inother namespaces. This feature provides a mechanism for service ownersand mesh administrators to control the visibility of virtual servicesacross namespace boundaries. If no namespaces are specified then the virtual service is exported to allnamespaces by default. The value “.” is reserved and defines an export to the same namespace thatthe virtual service is declared in. Similarly the value “” is reserved anddefines an export to all namespaces. NOTE: in the current release, the exportTo value is restricted to“.” or “*” (i.e., the current namespace or all namespaces). | No |
google.protobuf.UInt32Value
Wrapper message for uint32
.
The JSON representation for UInt32Value
is JSON number.
Field | Type | Description | Required |
---|---|---|---|
value | uint32 | The uint32 value. | No |