Istio速率限制错误(未配置请求的配额“ requestcount”)

时间:2018-09-21 16:16:58

标签: kubernetes rate-limiting istio

我正在从文档中跟踪此任务的“ Istio速率限制”部分: https://istio.io/docs/tasks/policy-enforcement/rate-limiting/

我已经正确设置了bookinfo应用程序,为productpage(以及bookinfo的所有其他组件)提供了虚拟服务,并且按原样运行它们的代码,但是速率限制对我来说不起作用。 / p>

每次我点击productpage的网址时,它都起作用,完全没有速率限制。但是,每次我访问该URL时,我都会在混合器日志中看到以下消息:

kubectl -n istio-system logs $(kubectl -n istio-system get pods -lapp=policy -o jsonpath='{.items[0].metadata.name}') -c mixer

2018-09-21T16:06:28.456449Z     warn    Requested quota 'requestcount' is not configured

虽然确实设置了请求计数配额:

apiVersion: "config.istio.io/v1alpha2"
kind: quota
metadata:
  name: requestcount
  namespace: istio-system
spec:
  dimensions:
    source: request.headers["x-forwarded-for"] | "unknown"
    destination: destination.labels["app"] | destination.service | "unknown"
    destinationVersion: destination.labels["version"] | "unknown"

应用完整的yaml文件时,我看到:

 memquota.config.istio.io "handler" configured
 quota.config.istio.io "requestcount" configured
 quotaspec.config.istio.io "request-count" configured
 quotaspecbinding.config.istio.io "request-count" configured
 rule.config.istio.io "quota" configured

如果我在跑步时看到以下内容

kubectl get quota requestcount -n istio-system -o yaml

apiVersion: config.istio.io/v1alpha2
kind: quota
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
  {"apiVersion":"config.istio.io/v1alpha2","kind":"quota","metadata":{"annotations":{},"name":"requestcount","namespace":"istio-system"},"spec":{"dimensions":{"destination":"destination.labels[\"app\"] | destination.service | \"unknown\"","destinationVersion":"destination.labels[\"version\"] | \"unknown\"","source":"request.headers[\"x-forwarded-for\"] | \"unknown\""}}}
  clusterName: ""
  creationTimestamp: 2018-09-21T16:02:23Z
  generation: 1
  name: requestcount
  namespace: istio-system
  resourceVersion: "263792"
  selfLink: /apis/config.istio.io/v1alpha2/namespaces/istio-system/quotas/requestcount
  uid: ba4d2510-bdb7-11e8-b8c9-025000000001
spec:
  dimensions:
    destination: destination.labels["app"] | destination.service | "unknown"
    destinationVersion: destination.labels["version"] | "unknown"
    source: request.headers["x-forwarded-for"] | "unknown"

那么为什么我会收到此消息?

1 个答案:

答案 0 :(得分:1)

我遇到这个问题并通过确保rulequota处于同一命名空间中来解决了该问题

---
apiVersion: "config.istio.io/v1alpha2"
kind: quota
metadata:
  name: requestcount
  namespace: istio-system
spec:
  dimensions:
    source: request.headers["x-forwarded-for"] | "unknown"
    destination: destination.labels["app"] | destination.service | "unknown"
    destinationVersion: destination.labels["version"] | "unknown"
---
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
  name: quota
  namespace: istio-system
spec:
  # quota only applies if you are not logged in.
  # match: match(request.headers["cookie"], "user=*") == false
  actions:
  - handler: handler.memquota
    instances:
    - requestcount.quota