1apiVersion: config.istio.io/v1alpha2
2kind: memquota
3metadata:
4  name: handler
5  namespace: istio-system
6spec:
7  quotas:
8  - name: requestcount.quota.istio-system
9    maxAmount: 500
10    validDuration: 1s
11    # The first matching override is applied.
12    # A requestcount instance is checked against override dimensions.
13    overrides:
14    # The following override applies to 'reviews' regardless
15    # of the source.
16    - dimensions:
17        destination: reviews
18      maxAmount: 1
19      validDuration: 5s
20    # The following override applies to 'productpage' when
21    # the source is a specific ip address.
22    - dimensions:
23        destination: productpage
24        source: "10.28.11.20"
25      maxAmount: 500
26      validDuration: 1s
27    # The following override applies to 'productpage' regardless
28    # of the source.
29    - dimensions:
30        destination: productpage
31      maxAmount: 2
32      validDuration: 5s
33---
34apiVersion: config.istio.io/v1alpha2
35kind: quota
36metadata:
37  name: requestcount
38  namespace: istio-system
39spec:
40  dimensions:
41    source: request.headers["x-forwarded-for"] | "unknown"
42    destination: destination.labels["app"] | destination.service.name | "unknown"
43    destinationVersion: destination.labels["version"] | "unknown"
44---
45apiVersion: config.istio.io/v1alpha2
46kind: QuotaSpec
47metadata:
48  name: request-count
49  namespace: istio-system
50spec:
51  rules:
52  - quotas:
53    - charge: 1
54      quota: requestcount
55---
56apiVersion: config.istio.io/v1alpha2
57kind: QuotaSpecBinding
58metadata:
59  name: request-count
60  namespace: istio-system
61spec:
62  quotaSpecs:
63  - name: request-count
64    namespace: istio-system
65  services:
66  - name: productpage
67    namespace: default
68    #  - service: '*'  # Uncomment this to bind *all* services to request-count
69---
70apiVersion: config.istio.io/v1alpha2
71kind: rule
72metadata:
73  name: quota
74  namespace: istio-system
75spec:
76  # quota only applies if you are not logged in.
77  # match: match(request.headers["cookie"], "user=*") == false
78  actions:
79  - handler: handler.memquota
80    instances:
81    - requestcount.quota
82