Fix a few formatting problems with the rate limiting doc.

This commit is contained in:
mtail 2018-05-31 07:38:56 -07:00
parent dcf7362976
commit f66eddc31b
4 changed files with 87 additions and 106 deletions

View File

@ -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:
```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:
{{< 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
GitHub raw content site (raw.githubusercontent.com) is CORS
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
If you move pages around and would like to ensure existing links continue to work, you can add

View File

@ -17,7 +17,7 @@ The latest Istio snapshot release is {{< istio_version >}} ([release notes](/abo
$ 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
$ curl -L https://git.io/getIstio | sh -

View File

@ -25,12 +25,12 @@ service.
$ 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`.
## 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
`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:
{{< 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:
```command
$ kubectl -n istio-system get memquota handler -o yaml
```command-output-as-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
overrides match, is `5000` requests per `1s`. Two overrides are also
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:
```command
$ kubectl -n istio-system get quotas requestcount -o yaml
```command-output-as-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
set overrides on request that match certain attributes. `destination` will
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:
```command
$ kubectl -n istio-system get rules quota -o yaml
```command-output-as-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
above) and pass it the object constructed using the instance
`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:
```command
$ kubectl -n istio-system get QuotaSpec request-count -o yaml
```command-output-as-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
charge of `1`.
1. Confirm the `QuotaSpecBinding` was created:
```command
$ kubectl -n istio-system get QuotaSpecBinding request-count -o yaml
```
```yaml
kind: QuotaSpecBinding
metadata:
name: request-count
namespace: istio-system
spec:
quotaSpecs:
- name: request-count
```command-output-as-yaml
$ kubectl -n istio-system get QuotaSpecBinding request-count -o yaml
kind: QuotaSpecBinding
metadata:
name: request-count
namespace: istio-system
services:
- name: ratings
namespace: default
- name: reviews
namespace: default
- name: details
namespace: default
- name: productpage
namespace: default
```
spec:
quotaSpecs:
- name: request-count
namespace: istio-system
services:
- name: ratings
namespace: default
- name: reviews
namespace: default
- name: details
namespace: default
- name: productpage
namespace: default
```
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

View File

@ -1,3 +1 @@
<div class="highlight">
<pre data-src="{{ .Get "url" }}"><code></code></pre>
</div>
<pre data-src="{{ .Get "url" }}"><code class="language-{{ .Get "lang" }}"></code></pre>