gpt4 book ai didi

kubernetes - Istio 速率限制错误(请求的配额 'requestcount' 未配置)

转载 作者:行者123 更新时间:2023-12-02 11:44:29 25 4
gpt4 key购买 nike

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

我已经正确设置了 bookinfo 应用程序,我有一个用于 productpage 的虚拟服务(以及 bookinfo 的所有其他组件),并且我正在按原样运行他们的代码,但速率限制对我不起作用。

每次我点击 productpage 的 url 时,它都会起作用,根本不会发生速率限制。但是,每次我点击 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

requestcount 配额肯定是设置的:
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"

那么为什么我会收到这条消息?

最佳答案

我遇到了这个问题并通过确保 rule 来修复它与 quota 在同一个命名空间中

---
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

关于kubernetes - Istio 速率限制错误(请求的配额 'requestcount' 未配置),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52447644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com