代码之家  ›  专栏  ›  技术社区  ›  enator

如何在istio中调试速率限制的QuotaSpecBinding?

  •  1
  • enator  · 技术社区  · 6 年前

    我正在尝试为已启用istio的服务启用速率限制。但没用。如果配置正确,如何调试?

    apiVersion: config.istio.io/v1alpha2
    kind: memquota
    metadata:
      name: handler
      namespace: istio-system
    spec:
      quotas:
      - name: requestcount.quota.istio-system
        maxAmount: 5
        validDuration: 1s
        overrides:
        - dimensions:
            engine: myEngineValue
          maxAmount: 5
          validDuration: 1s
    ---
    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"
        engine: destination.labels["engine"] | "unknown"
    ---
    apiVersion: config.istio.io/v1alpha2
    kind: QuotaSpec
    metadata:
      name: request-count
      namespace: istio-system
    spec:
      rules:
      - quotas:
        - charge: 1
          quota: requestcount
    ---
    apiVersion: config.istio.io/v1alpha2
    kind: QuotaSpecBinding
    metadata:
      name: request-count
      namespace: istio-system
    spec:
      quotaSpecs:
      - name: request-count
        namespace: istio-system
      services:
      # - service: '*' ; I tried with this as well
      - name: my-service
        namespace: default
    ---
    apiVersion: config.istio.io/v1alpha2
    kind: rule
    metadata:
      name: quota
      namespace: istio-system
    spec:
      actions:
      - handler: handler.memquota
        instances:
        - requestcount.quota
    

    我试过了 - service: '*' 以及在 QuotaSpecBinding ;但没有运气。

    如何确认我的配置是否正确?这个 my-service 是我部署的kubernetes服务。(这必须是istio的虚拟服务才能实现速率限制吗? 编辑:是的,必须这样! )

    我跟着 this doc

    我有一种感觉,在名字空间的某个地方,我犯了一个错误。

    1 回复  |  直到 6 年前
        1
  •  2
  •   Xavier Canal Masjuan    6 年前

    必须为服务定义虚拟服务 my-service :

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: myservice
    spec:
      hosts:
      - myservice
      http:
      - route:
        - destination:
            host: myservice
    

    这样,您就可以让Istio知道您所指的是哪个服务。

    在调试方面,我知道有一个名为 Kiali 其目的是利用Istio环境中的可观测性。我知道他们对一些Istio和Kubernetes对象进行了验证: Istio configuration browse .