Skip to content

Instantly share code, notes, and snippets.

@pichuang
Last active December 5, 2019 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pichuang/a892b8cbada81a3b96810f145fa2ae26 to your computer and use it in GitHub Desktop.
Save pichuang/a892b8cbada81a3b96810f145fa2ae26 to your computer and use it in GitHub Desktop.
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: quota
namespace: istio-system
spec:
actions:
- handler: handler.memquota
instances:
- requestcount.quota
match: match(request.headers["cookie"], "user=tester") == false
apiVersion: "config.istio.io/v1alpha2"
kind: memquota
metadata:
name: handler
namespace: istio-system
spec:
quotas:
- name: requestcount.quota.istio-system
maxAmount: 200
validDuration: 1s
overrides:
- dimensions:
destination: reviews
maxAmount: 4
validDuration: 5s
@pichuang
Copy link
Author

pichuang commented Dec 5, 2019

rate_limit.yaml: Memquota 規定 reviews 服務在 5 秒內最多能被訪問 4 次

@pichuang
Copy link
Author

pichuang commented Dec 5, 2019

Istio 速率限制可以讓 普通用戶在使用reviews 服務時,只被提供免費的 quota,若超過免費 quota 的請求,則被限制。
rate_limit-advanced,yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment