slime-io / slime

An intelligent ServiceMesh manager based on Istio
https://slime-io.github.io/
Other
424 stars 78 forks source link

限流规则未生效 #372

Closed xdccy closed 1 year ago

xdccy commented 1 year ago

问题描述 提交全局共享限流每分钟10次的规则后,使用for i in $(seq 25); do curl -H "foo:bar" -I http://productpage.default:9080/productpage; done的命令访问productpage服务,但是限流没有生效。已生成了configMap和EnvoyFilter资源。 SmartLimiter资源如下:

apiVersion: microservice.slime.io/v1alpha2
kind: SmartLimiter
metadata:
  name: productpage
  namespace: default
  resourceVersion: "221307742"
  uid: 1d372ffb-2a8c-4848-8f1f-3eee433d3ba7
spec:
  sets:
    _base:
      descriptor:
      - action:
          fill_interval:
            seconds: 60
          quota: "10"
          strategy: global
        condition: "true"
        target:
          port: 9080
status:
  metricStatus:
    _base.pod: "2"
    cpu.sum: "949.765976114"
  ratelimitStatus:
    _base:
      descriptor:
      - action:
          fillInterval:
            seconds: "60"
          quota: "10"
          strategy: global
        target:
          port: 9080

configMap如下:

domain: slime
 descriptors:
 - key: generic_key
   value: Service[productpage.default]-Id[2970232041]
   rate_limit:
     requests_per_unit: 10
     unit: MINUTE`

生成的envoyfiter如下:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: productpage.default.ratelimit
  namespace: default
  ownerReferences:
  - apiVersion: microservice.slime.io/v1alpha2
    blockOwnerDeletion: true
    controller: true
    kind: SmartLimiter
    name: productpage
    uid: b0bba30d-504b-40b3-9c50-7bddd8e3f425
  resourceVersion: "191000099"
  uid: c4f70ada-2158-4e11-bcdc-2c827a0243a0
spec:
  configPatches:
  - applyTo: HTTP_ROUTE
    match:
      context: SIDECAR_INBOUND
      routeConfiguration:
        vhost:
          name: inbound|http|9080
          route:
            name: default
    patch:
      operation: MERGE
      value:
        route:
          rate_limits:
          - actions:
            - generic_key:
                descriptor_value: Service[productpage.default]-Id[2970232041]
  - applyTo: HTTP_FILTER
    match:
      context: SIDECAR_INBOUND
      listener:
        filterChain:
          filter:
            name: envoy.filters.network.http_connection_manager
            subFilter:
              name: envoy.filters.http.router
    patch:
      operation: INSERT_BEFORE
      value:
        name: envoy.filters.http.ratelimit
        typed_config:
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
          value:
            domain: slime
            rate_limit_service:
              grpc_service:
                envoy_grpc:
                  cluster_name: outbound|18081||rate-limit.mesh-operator.svc.cluster.local
              transport_api_version: V3
  workloadSelector:
    labels:
      app: productpage

影响的子模块(在下面列表中打'X')

重现问题的步骤 应用上述规则进行限流访问。

MouceL commented 1 year ago

重新组织下格式吧 @xdccy

MouceL commented 1 year ago

ref: https://github.com/slime-io/slime/issues/217

xdccy commented 1 year ago

ref: #217 配置都有打开

MouceL commented 1 year ago

由于是通过configmap挂载进容器

生效较慢

xdccy commented 1 year ago

由于是通过configmap挂载进容器

生效较慢

是在两个集群部署了两套相同的服务,一个集群一切正常,另一个集群中的限流规则(单机限流、全局限流等)都没有生效,但是对比了两个集群生成的envoyfilter、configMap等都是相同的