mirror of https://github.com/istio/istio.io.git
Fix a few formatting problems with the rate limiting doc.
This commit is contained in:
parent
dcf7362976
commit
f66eddc31b
|
@ -283,19 +283,16 @@ You can pull in an external file and display its content as a preformatted block
|
||||||
config file or a test file. To do so, you use a statement such as:
|
config file or a test file. To do so, you use a statement such as:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
{{</* file_content url="https://raw.githubusercontent.com/istio/istio/master/Makefile" */>}}
|
{{</* file_content url="https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/kube/mixer-rule-ratings-ratelimit.yaml" lang="yaml" */>}}
|
||||||
```
|
```
|
||||||
which produces the following result:
|
which produces the following result:
|
||||||
|
|
||||||
{{< file_content url="https://raw.githubusercontent.com/istio/istio/master/Makefile" >}}
|
{{< file_content url="https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/kube/mixer-rule-ratings-ratelimit.yaml" lang="yaml" >}}
|
||||||
|
|
||||||
If the file is from a different origin site, CORS should be enabled on that site. Note that the
|
If the file is from a different origin site, CORS should be enabled on that site. Note that the
|
||||||
GitHub raw content site (raw.githubusercontent.com) is CORS
|
GitHub raw content site (raw.githubusercontent.com) is CORS
|
||||||
enabled so it may be used here.
|
enabled so it may be used here.
|
||||||
|
|
||||||
Note that unlike normal preformatted blocks, dynamically loaded preformatted blocks unfortunately
|
|
||||||
do not get syntax colored.
|
|
||||||
|
|
||||||
## Renaming or moving pages
|
## Renaming or moving pages
|
||||||
|
|
||||||
If you move pages around and would like to ensure existing links continue to work, you can add
|
If you move pages around and would like to ensure existing links continue to work, you can add
|
||||||
|
|
|
@ -17,7 +17,7 @@ The latest Istio snapshot release is {{< istio_version >}} ([release notes](/abo
|
||||||
$ curl -L https://git.io/getLatestIstio | sh -
|
$ curl -L https://git.io/getLatestIstio | sh -
|
||||||
```
|
```
|
||||||
|
|
||||||
The most recent stable release is 0.8. You can [download 0.8](https://github.com/istio/istio/releases/tag/0.8) with:
|
The most recent stable release is 0.8. You can download 0.8 with:
|
||||||
|
|
||||||
```command
|
```command
|
||||||
$ curl -L https://git.io/getIstio | sh -
|
$ curl -L https://git.io/getIstio | sh -
|
||||||
|
|
|
@ -25,12 +25,12 @@ service.
|
||||||
$ istioctl create -f samples/bookinfo/kube/route-rule-reviews-v3.yaml
|
$ istioctl create -f samples/bookinfo/kube/route-rule-reviews-v3.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
> If you have conflicting rule that you set in previous tasks,
|
> If you have a conflicting rule that you set in previous tasks,
|
||||||
use `istioctl replace` instead of `istioctl create`.
|
use `istioctl replace` instead of `istioctl create`.
|
||||||
|
|
||||||
## Rate limits
|
## Rate limits
|
||||||
|
|
||||||
Istio enables users to rate limit traffic to a service.
|
Istio enables you to rate limit traffic to a service.
|
||||||
|
|
||||||
Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
||||||
`1qps` free quota. Using Istio we can ensure that `1qps` is not breached.
|
`1qps` free quota. Using Istio we can ensure that `1qps` is not breached.
|
||||||
|
@ -54,38 +54,36 @@ Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
||||||
```
|
```
|
||||||
|
|
||||||
The file looks like:
|
The file looks like:
|
||||||
{{< file_content url="https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/kube/mixer-rule-ratings-ratelimit.yaml" >}}
|
|
||||||
|
{{< file_content url="https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/kube/mixer-rule-ratings-ratelimit.yaml" lang="yaml" >}}
|
||||||
|
|
||||||
1. Confirm the `memquota` was created:
|
1. Confirm the `memquota` was created:
|
||||||
|
|
||||||
```command
|
```command-output-as-yaml
|
||||||
$ kubectl -n istio-system get memquota handler -o yaml
|
$ kubectl -n istio-system get memquota handler -o yaml
|
||||||
|
apiVersion: config.istio.io/v1alpha2
|
||||||
|
kind: memquota
|
||||||
|
metadata:
|
||||||
|
name: handler
|
||||||
|
namespace: istio-system
|
||||||
|
spec:
|
||||||
|
quotas:
|
||||||
|
- name: requestcount.quota.istio-system
|
||||||
|
maxAmount: 5000
|
||||||
|
validDuration: 1s
|
||||||
|
overrides:
|
||||||
|
- dimensions:
|
||||||
|
destination: ratings
|
||||||
|
source: reviews
|
||||||
|
sourceVersion: v3
|
||||||
|
maxAmount: 1
|
||||||
|
validDuration: 5s
|
||||||
|
- dimensions:
|
||||||
|
destination: ratings
|
||||||
|
maxAmount: 5
|
||||||
|
validDuration: 10s
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: config.istio.io/v1alpha2
|
|
||||||
kind: memquota
|
|
||||||
metadata:
|
|
||||||
name: handler
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
quotas:
|
|
||||||
- name: requestcount.quota.istio-system
|
|
||||||
maxAmount: 5000
|
|
||||||
validDuration: 1s
|
|
||||||
overrides:
|
|
||||||
- dimensions:
|
|
||||||
destination: ratings
|
|
||||||
source: reviews
|
|
||||||
sourceVersion: v3
|
|
||||||
maxAmount: 1
|
|
||||||
validDuration: 5s
|
|
||||||
- dimensions:
|
|
||||||
destination: ratings
|
|
||||||
maxAmount: 5
|
|
||||||
validDuration: 10s
|
|
||||||
```
|
|
||||||
|
|
||||||
The `memquota` defines 3 different rate limit schemes. The default, if no
|
The `memquota` defines 3 different rate limit schemes. The default, if no
|
||||||
overrides match, is `5000` requests per `1s`. Two overrides are also
|
overrides match, is `5000` requests per `1s`. Two overrides are also
|
||||||
defined. The first is `1` request every `5s` if the `destination` is
|
defined. The first is `1` request every `5s` if the `destination` is
|
||||||
|
@ -95,24 +93,21 @@ Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
||||||
|
|
||||||
1. Confirm the `quota` was created:
|
1. Confirm the `quota` was created:
|
||||||
|
|
||||||
```command
|
```command-output-as-yaml
|
||||||
$ kubectl -n istio-system get quotas requestcount -o yaml
|
$ kubectl -n istio-system get quotas requestcount -o yaml
|
||||||
|
apiVersion: config.istio.io/v1alpha2
|
||||||
|
kind: quota
|
||||||
|
metadata:
|
||||||
|
name: requestcount
|
||||||
|
namespace: istio-system
|
||||||
|
spec:
|
||||||
|
dimensions:
|
||||||
|
source: source.labels["app"] | source.service | "unknown"
|
||||||
|
sourceVersion: source.labels["version"] | "unknown"
|
||||||
|
destination: destination.labels["app"] | destination.service | "unknown"
|
||||||
|
destinationVersion: destination.labels["version"] | "unknown"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: config.istio.io/v1alpha2
|
|
||||||
kind: quota
|
|
||||||
metadata:
|
|
||||||
name: requestcount
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
dimensions:
|
|
||||||
source: source.labels["app"] | source.service | "unknown"
|
|
||||||
sourceVersion: source.labels["version"] | "unknown"
|
|
||||||
destination: destination.labels["app"] | destination.service | "unknown"
|
|
||||||
destinationVersion: destination.labels["version"] | "unknown"
|
|
||||||
```
|
|
||||||
|
|
||||||
The `quota` template defines 4 `dimensions` that are used by `memquota` to
|
The `quota` template defines 4 `dimensions` that are used by `memquota` to
|
||||||
set overrides on request that match certain attributes. `destination` will
|
set overrides on request that match certain attributes. `destination` will
|
||||||
be set to the first non-empty value in `destination.labels["app"]`,
|
be set to the first non-empty value in `destination.labels["app"]`,
|
||||||
|
@ -122,23 +117,20 @@ Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
||||||
|
|
||||||
1. Confirm the `rule` was created:
|
1. Confirm the `rule` was created:
|
||||||
|
|
||||||
```command
|
```command-output-as-yaml
|
||||||
$ kubectl -n istio-system get rules quota -o yaml
|
$ kubectl -n istio-system get rules quota -o yaml
|
||||||
|
apiVersion: config.istio.io/v1alpha2
|
||||||
|
kind: rule
|
||||||
|
metadata:
|
||||||
|
name: quota
|
||||||
|
namespace: istio-system
|
||||||
|
spec:
|
||||||
|
actions:
|
||||||
|
- handler: handler.memquota
|
||||||
|
instances:
|
||||||
|
- requestcount.quota
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: config.istio.io/v1alpha2
|
|
||||||
kind: rule
|
|
||||||
metadata:
|
|
||||||
name: quota
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
actions:
|
|
||||||
- handler: handler.memquota
|
|
||||||
instances:
|
|
||||||
- requestcount.quota
|
|
||||||
```
|
|
||||||
|
|
||||||
The `rule` tells mixer to invoke `handler.memquota` handler (created
|
The `rule` tells mixer to invoke `handler.memquota` handler (created
|
||||||
above) and pass it the object constructed using the instance
|
above) and pass it the object constructed using the instance
|
||||||
`requestcount.quota` (also created above). This effectively maps the
|
`requestcount.quota` (also created above). This effectively maps the
|
||||||
|
@ -146,51 +138,45 @@ Consider `ratings` as an external paid service like Rotten Tomatoes® with
|
||||||
|
|
||||||
1. Confirm the `QuotaSpec` was created:
|
1. Confirm the `QuotaSpec` was created:
|
||||||
|
|
||||||
```command
|
```command-output-as-yaml
|
||||||
$ kubectl -n istio-system get QuotaSpec request-count -o yaml
|
$ kubectl -n istio-system get QuotaSpec request-count -o yaml
|
||||||
|
apiVersion: config.istio.io/v1alpha2
|
||||||
|
kind: QuotaSpec
|
||||||
|
metadata:
|
||||||
|
name: request-count
|
||||||
|
namespace: istio-system
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- quotas:
|
||||||
|
- charge: "1"
|
||||||
|
quota: requestcount
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: config.istio.io/v1alpha2
|
|
||||||
kind: QuotaSpec
|
|
||||||
metadata:
|
|
||||||
name: request-count
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- quotas:
|
|
||||||
- charge: "1"
|
|
||||||
quota: requestcount
|
|
||||||
```
|
|
||||||
|
|
||||||
This `QuotaSpec` defines the requestcount `quota` we created above with a
|
This `QuotaSpec` defines the requestcount `quota` we created above with a
|
||||||
charge of `1`.
|
charge of `1`.
|
||||||
|
|
||||||
1. Confirm the `QuotaSpecBinding` was created:
|
1. Confirm the `QuotaSpecBinding` was created:
|
||||||
|
|
||||||
```command
|
```command-output-as-yaml
|
||||||
$ kubectl -n istio-system get QuotaSpecBinding request-count -o yaml
|
$ kubectl -n istio-system get QuotaSpecBinding request-count -o yaml
|
||||||
```
|
kind: QuotaSpecBinding
|
||||||
|
metadata:
|
||||||
```yaml
|
name: request-count
|
||||||
kind: QuotaSpecBinding
|
|
||||||
metadata:
|
|
||||||
name: request-count
|
|
||||||
namespace: istio-system
|
|
||||||
spec:
|
|
||||||
quotaSpecs:
|
|
||||||
- name: request-count
|
|
||||||
namespace: istio-system
|
namespace: istio-system
|
||||||
services:
|
spec:
|
||||||
- name: ratings
|
quotaSpecs:
|
||||||
namespace: default
|
- name: request-count
|
||||||
- name: reviews
|
namespace: istio-system
|
||||||
namespace: default
|
services:
|
||||||
- name: details
|
- name: ratings
|
||||||
namespace: default
|
namespace: default
|
||||||
- name: productpage
|
- name: reviews
|
||||||
namespace: default
|
namespace: default
|
||||||
```
|
- name: details
|
||||||
|
namespace: default
|
||||||
|
- name: productpage
|
||||||
|
namespace: default
|
||||||
|
```
|
||||||
|
|
||||||
This `QuotaSpecBinding` binds the `QuotaSpec` we created above to the
|
This `QuotaSpecBinding` binds the `QuotaSpec` we created above to the
|
||||||
services we want to apply it to. Note we have to define the namespace for
|
services we want to apply it to. Note we have to define the namespace for
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
<div class="highlight">
|
<pre data-src="{{ .Get "url" }}"><code class="language-{{ .Get "lang" }}"></code></pre>
|
||||||
<pre data-src="{{ .Get "url" }}"><code></code></pre>
|
|
||||||
</div>
|
|
Loading…
Reference in New Issue