mirror of https://github.com/istio/istio.io.git
Automator: update istio.io@ reference docs (#11549)
This commit is contained in:
parent
d004fead48
commit
972a2ea690
|
@ -628,6 +628,19 @@ connections. Arbitrary IPs are not supported. Format should be one of <code>127.
|
||||||
Yes
|
Yes
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr id="IstioIngressListener-tls">
|
||||||
|
<td><code>tls</code></td>
|
||||||
|
<td><code><a href="/docs/reference/config/networking/gateway/#ServerTLSSettings">ServerTLSSettings</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>Set of TLS related options that will enable TLS termination on the
|
||||||
|
sidecar for requests originating from outside the mesh.
|
||||||
|
Currently supports only SIMPLE and MUTUAL TLS modes.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -8,7 +8,7 @@ layout: protoc-gen-docs
|
||||||
generator: protoc-gen-docs
|
generator: protoc-gen-docs
|
||||||
schema: istio.networking.v1alpha3.VirtualService
|
schema: istio.networking.v1alpha3.VirtualService
|
||||||
aliases: [/docs/reference/config/networking/v1alpha3/virtual-service]
|
aliases: [/docs/reference/config/networking/v1alpha3/virtual-service]
|
||||||
number_of_entries: 25
|
number_of_entries: 27
|
||||||
---
|
---
|
||||||
<p>Configuration affecting traffic routing. Here are a few terms useful to define
|
<p>Configuration affecting traffic routing. Here are a few terms useful to define
|
||||||
in the context of traffic routing.</p>
|
in the context of traffic routing.</p>
|
||||||
|
@ -669,8 +669,8 @@ No
|
||||||
<td><code>route</code></td>
|
<td><code>route</code></td>
|
||||||
<td><code><a href="#HTTPRouteDestination">HTTPRouteDestination[]</a></code></td>
|
<td><code><a href="#HTTPRouteDestination">HTTPRouteDestination[]</a></code></td>
|
||||||
<td>
|
<td>
|
||||||
<p>A HTTP rule can either redirect or forward (default) traffic. The
|
<p>A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
|
||||||
forwarding target can be one of several versions of a service (see
|
The forwarding target can be one of several versions of a service (see
|
||||||
glossary in beginning of document). Weights associated with the
|
glossary in beginning of document). Weights associated with the
|
||||||
service version determine the proportion of traffic it receives.</p>
|
service version determine the proportion of traffic it receives.</p>
|
||||||
|
|
||||||
|
@ -683,11 +683,26 @@ No
|
||||||
<td><code>redirect</code></td>
|
<td><code>redirect</code></td>
|
||||||
<td><code><a href="#HTTPRedirect">HTTPRedirect</a></code></td>
|
<td><code><a href="#HTTPRedirect">HTTPRedirect</a></code></td>
|
||||||
<td>
|
<td>
|
||||||
<p>A HTTP rule can either redirect or forward (default) traffic. If
|
<p>A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
|
||||||
traffic passthrough option is specified in the rule,
|
If traffic passthrough option is specified in the rule,
|
||||||
route/redirect will be ignored. The redirect primitive can be used to
|
route/redirect will be ignored. The redirect primitive can be used to
|
||||||
send a HTTP 301 redirect to a different URI or Authority.</p>
|
send a HTTP 301 redirect to a different URI or Authority.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPRoute-direct_response">
|
||||||
|
<td><code>directResponse</code></td>
|
||||||
|
<td><code><a href="#HTTPDirectResponse">HTTPDirectResponse</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>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.</p>
|
||||||
|
|
||||||
|
<p>It can be set only when <code>Route</code> and <code>Redirect</code> are empty.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
@ -1515,6 +1530,22 @@ No
|
||||||
If the VirtualService has a list of gateways specified in the top-level <code>gateways</code> field,
|
If the VirtualService has a list of gateways specified in the top-level <code>gateways</code> field,
|
||||||
it must include the reserved gateway <code>mesh</code> for this field to be applicable.</p>
|
it must include the reserved gateway <code>mesh</code> for this field to be applicable.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPMatchRequest-stat_prefix">
|
||||||
|
<td><code>statPrefix</code></td>
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td>
|
||||||
|
<p>The human readable prefix to use when emitting statistics for this route.
|
||||||
|
The statistics are generated with prefix route.<stat_prefix>.
|
||||||
|
This should be set for highly critical routes that one wishes to get “per-route” statistics on.
|
||||||
|
This prefix is only for proxy-level statistics (envoy<em>*) and not service-level (istio</em>*) statistics.
|
||||||
|
Refer to https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-field-config-route-v3-route-stat-prefix
|
||||||
|
for statistics that are generated when this is configured.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
@ -2073,6 +2104,238 @@ No
|
||||||
<p>On a redirect, Specifies the HTTP status code to use in the redirect
|
<p>On a redirect, Specifies the HTTP status code to use in the redirect
|
||||||
response. The default response code is MOVED_PERMANENTLY (301).</p>
|
response. The default response code is MOVED_PERMANENTLY (301).</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
<h2 id="HTTPDirectResponse">HTTPDirectResponse</h2>
|
||||||
|
<section>
|
||||||
|
<p>HTTPDirectResponse can be used to send a fixed response to clients.
|
||||||
|
For example, the following rule returns a fixed 503 status with a body
|
||||||
|
to requests for /v1/getProductRatings API.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "unknown error"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "unknown error"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<p>It is also possible to specify a binary response body.
|
||||||
|
This is mostly useful for non text-based protocols such as gRPC.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
bytes: "dW5rbm93biBlcnJvcg==" # "unknown error" in base64
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
bytes: "dW5rbm93biBlcnJvcg==" # "unknown error" in base64
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<p>It is good practice to add headers in the HTTPRoute
|
||||||
|
as well as the direct_response, for example to specify
|
||||||
|
the returned Content-Type.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "{\"error\": \"unknown error\"}"
|
||||||
|
headers:
|
||||||
|
response:
|
||||||
|
set:
|
||||||
|
content-type: "appliation/json"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "{\"error\": \"unknown error\"}"
|
||||||
|
headers:
|
||||||
|
response:
|
||||||
|
set:
|
||||||
|
content-type: "text/plain"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<table class="message-fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Required</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="HTTPDirectResponse-status">
|
||||||
|
<td><code>status</code></td>
|
||||||
|
<td><code>uint32</code></td>
|
||||||
|
<td>
|
||||||
|
<p>Specifies the HTTP response status to be returned.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Yes
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPDirectResponse-body">
|
||||||
|
<td><code>body</code></td>
|
||||||
|
<td><code><a href="#HTTPBody">HTTPBody</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>Specifies the content of the response body. If this setting is omitted,
|
||||||
|
no body is included in the generated response.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
<h2 id="HTTPBody">HTTPBody</h2>
|
||||||
|
<section>
|
||||||
|
<table class="message-fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Required</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="HTTPBody-string" class="oneof oneof-start">
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td><code>string (oneof)</code></td>
|
||||||
|
<td>
|
||||||
|
<p>response body as a string</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPBody-bytes" class="oneof">
|
||||||
|
<td><code>bytes</code></td>
|
||||||
|
<td><code>bytes (oneof)</code></td>
|
||||||
|
<td>
|
||||||
|
<p>response body as base64 encoded bytes.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
|
|
@ -628,6 +628,19 @@ connections. Arbitrary IPs are not supported. Format should be one of <code>127.
|
||||||
Yes
|
Yes
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr id="IstioIngressListener-tls">
|
||||||
|
<td><code>tls</code></td>
|
||||||
|
<td><code><a href="/zh/docs/reference/config/networking/gateway/#ServerTLSSettings">ServerTLSSettings</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>Set of TLS related options that will enable TLS termination on the
|
||||||
|
sidecar for requests originating from outside the mesh.
|
||||||
|
Currently supports only SIMPLE and MUTUAL TLS modes.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -8,7 +8,7 @@ layout: protoc-gen-docs
|
||||||
generator: protoc-gen-docs
|
generator: protoc-gen-docs
|
||||||
schema: istio.networking.v1alpha3.VirtualService
|
schema: istio.networking.v1alpha3.VirtualService
|
||||||
aliases: [/zh/docs/reference/config/networking/v1alpha3/virtual-service]
|
aliases: [/zh/docs/reference/config/networking/v1alpha3/virtual-service]
|
||||||
number_of_entries: 25
|
number_of_entries: 27
|
||||||
---
|
---
|
||||||
<p>Configuration affecting traffic routing. Here are a few terms useful to define
|
<p>Configuration affecting traffic routing. Here are a few terms useful to define
|
||||||
in the context of traffic routing.</p>
|
in the context of traffic routing.</p>
|
||||||
|
@ -669,8 +669,8 @@ No
|
||||||
<td><code>route</code></td>
|
<td><code>route</code></td>
|
||||||
<td><code><a href="#HTTPRouteDestination">HTTPRouteDestination[]</a></code></td>
|
<td><code><a href="#HTTPRouteDestination">HTTPRouteDestination[]</a></code></td>
|
||||||
<td>
|
<td>
|
||||||
<p>A HTTP rule can either redirect or forward (default) traffic. The
|
<p>A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
|
||||||
forwarding target can be one of several versions of a service (see
|
The forwarding target can be one of several versions of a service (see
|
||||||
glossary in beginning of document). Weights associated with the
|
glossary in beginning of document). Weights associated with the
|
||||||
service version determine the proportion of traffic it receives.</p>
|
service version determine the proportion of traffic it receives.</p>
|
||||||
|
|
||||||
|
@ -683,11 +683,26 @@ No
|
||||||
<td><code>redirect</code></td>
|
<td><code>redirect</code></td>
|
||||||
<td><code><a href="#HTTPRedirect">HTTPRedirect</a></code></td>
|
<td><code><a href="#HTTPRedirect">HTTPRedirect</a></code></td>
|
||||||
<td>
|
<td>
|
||||||
<p>A HTTP rule can either redirect or forward (default) traffic. If
|
<p>A HTTP rule can either return a direct_response, redirect or forward (default) traffic.
|
||||||
traffic passthrough option is specified in the rule,
|
If traffic passthrough option is specified in the rule,
|
||||||
route/redirect will be ignored. The redirect primitive can be used to
|
route/redirect will be ignored. The redirect primitive can be used to
|
||||||
send a HTTP 301 redirect to a different URI or Authority.</p>
|
send a HTTP 301 redirect to a different URI or Authority.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPRoute-direct_response">
|
||||||
|
<td><code>directResponse</code></td>
|
||||||
|
<td><code><a href="#HTTPDirectResponse">HTTPDirectResponse</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>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.</p>
|
||||||
|
|
||||||
|
<p>It can be set only when <code>Route</code> and <code>Redirect</code> are empty.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
@ -1515,6 +1530,22 @@ No
|
||||||
If the VirtualService has a list of gateways specified in the top-level <code>gateways</code> field,
|
If the VirtualService has a list of gateways specified in the top-level <code>gateways</code> field,
|
||||||
it must include the reserved gateway <code>mesh</code> for this field to be applicable.</p>
|
it must include the reserved gateway <code>mesh</code> for this field to be applicable.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPMatchRequest-stat_prefix">
|
||||||
|
<td><code>statPrefix</code></td>
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td>
|
||||||
|
<p>The human readable prefix to use when emitting statistics for this route.
|
||||||
|
The statistics are generated with prefix route.<stat_prefix>.
|
||||||
|
This should be set for highly critical routes that one wishes to get “per-route” statistics on.
|
||||||
|
This prefix is only for proxy-level statistics (envoy<em>*) and not service-level (istio</em>*) statistics.
|
||||||
|
Refer to https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-field-config-route-v3-route-stat-prefix
|
||||||
|
for statistics that are generated when this is configured.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
@ -2073,6 +2104,238 @@ No
|
||||||
<p>On a redirect, Specifies the HTTP status code to use in the redirect
|
<p>On a redirect, Specifies the HTTP status code to use in the redirect
|
||||||
response. The default response code is MOVED_PERMANENTLY (301).</p>
|
response. The default response code is MOVED_PERMANENTLY (301).</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
<h2 id="HTTPDirectResponse">HTTPDirectResponse</h2>
|
||||||
|
<section>
|
||||||
|
<p>HTTPDirectResponse can be used to send a fixed response to clients.
|
||||||
|
For example, the following rule returns a fixed 503 status with a body
|
||||||
|
to requests for /v1/getProductRatings API.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "unknown error"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "unknown error"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<p>It is also possible to specify a binary response body.
|
||||||
|
This is mostly useful for non text-based protocols such as gRPC.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
bytes: "dW5rbm93biBlcnJvcg==" # "unknown error" in base64
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
bytes: "dW5rbm93biBlcnJvcg==" # "unknown error" in base64
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<p>It is good practice to add headers in the HTTPRoute
|
||||||
|
as well as the direct_response, for example to specify
|
||||||
|
the returned Content-Type.</p>
|
||||||
|
|
||||||
|
<p>{{<tabset category-name="example">}}
|
||||||
|
{{<tab name="v1alpha3" category-value="v1alpha3">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1alpha3
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "{\"error\": \"unknown error\"}"
|
||||||
|
headers:
|
||||||
|
response:
|
||||||
|
set:
|
||||||
|
content-type: "appliation/json"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}</p>
|
||||||
|
|
||||||
|
<p>{{<tab name="v1beta1" category-value="v1beta1">}}</p>
|
||||||
|
|
||||||
|
<pre><code class="language-yaml">apiVersion: networking.istio.io/v1beta1
|
||||||
|
kind: VirtualService
|
||||||
|
metadata:
|
||||||
|
name: ratings-route
|
||||||
|
spec:
|
||||||
|
hosts:
|
||||||
|
- ratings.prod.svc.cluster.local
|
||||||
|
http:
|
||||||
|
- match:
|
||||||
|
- uri:
|
||||||
|
exact: /v1/getProductRatings
|
||||||
|
directResponse:
|
||||||
|
status: 503
|
||||||
|
body:
|
||||||
|
string: "{\"error\": \"unknown error\"}"
|
||||||
|
headers:
|
||||||
|
response:
|
||||||
|
set:
|
||||||
|
content-type: "text/plain"
|
||||||
|
...
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>{{</tab>}}
|
||||||
|
{{</tabset>}}</p>
|
||||||
|
|
||||||
|
<table class="message-fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Required</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="HTTPDirectResponse-status">
|
||||||
|
<td><code>status</code></td>
|
||||||
|
<td><code>uint32</code></td>
|
||||||
|
<td>
|
||||||
|
<p>Specifies the HTTP response status to be returned.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Yes
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPDirectResponse-body">
|
||||||
|
<td><code>body</code></td>
|
||||||
|
<td><code><a href="#HTTPBody">HTTPBody</a></code></td>
|
||||||
|
<td>
|
||||||
|
<p>Specifies the content of the response body. If this setting is omitted,
|
||||||
|
no body is included in the generated response.</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
<h2 id="HTTPBody">HTTPBody</h2>
|
||||||
|
<section>
|
||||||
|
<table class="message-fields">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Required</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr id="HTTPBody-string" class="oneof oneof-start">
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td><code>string (oneof)</code></td>
|
||||||
|
<td>
|
||||||
|
<p>response body as a string</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr id="HTTPBody-bytes" class="oneof">
|
||||||
|
<td><code>bytes</code></td>
|
||||||
|
<td><code>bytes (oneof)</code></td>
|
||||||
|
<td>
|
||||||
|
<p>response body as base64 encoded bytes.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
No
|
No
|
||||||
|
|
Loading…
Reference in New Issue