首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在特使中配置本地限速?

如何在特使中配置本地限速?
EN

Stack Overflow用户
提问于 2020-07-21 16:14:36
回答 1查看 1.1K关注 0票数 1

我想只为一个特使代理启用local rate limiter,而不需要额外的现场速率限制服务。我使用的版本是1.13.1。

我已经尝试将配置直接添加到过滤器链中:

代码语言:javascript
复制
static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.local_ratelimit
        stat_prefix: local_rate_limiter
        token_bucket: 
          max_tokens: 1000
          tokens_per_fill: 100
          fill_interval: 
            seconds: 1
      - name: envoy.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
          codec_type: auto
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/application"
                route:
                  cluster: application
          http_filters:
          - name: envoy.router
            typed_config: {}
  clusters:
  - name: application
    connect_timeout: 0.25s
    type: strict_dns
    lb_policy: round_robin
    http2_protocol_options: {}
    health_checks:
      timeout: 2s
      interval: 5s
      unhealthy_threshold: 2
      healthy_threshold: 1
      http_health_check:
        # path: "/application/health/live"
        path: "/application/health/ready"
    outlier_detection:
      consecutive_5xx: 3
      interval: 5s
      base_ejection_time: 30s
      max_ejection_percent: 50
    load_assignment:
      cluster_name: application
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: application-1
                port_value: 8080
        - endpoint:
            address:
              socket_address:
                address: application-2
                port_value: 8080
                
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

启动Docker容器时,我收到以下错误:

代码语言:javascript
复制
[2020-07-21 08:03:03.717][1][critical][main] [source/server/server.cc:94] error initializing configuration '/etc/envoy/envoy.yaml': Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:(static_resources.listeners[0].filter_chains[0].filters[0]) token_bucket: Cannot find field.) has unknown fields
[2020-07-21 08:03:03.717][1][info][main] [source/server/server.cc:595] exiting
Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:(static_resources.listeners[0].filter_chains[0].filters[0]) token_bucket: Cannot find field.) has unknown fields
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-21 16:14:36

好了,我刚刚发现过滤器链中的每个filter都需要一个typed_config元素,该元素应该与我打算使用的类型相匹配。首先,我试图引用GitHub代码库中的wrong definition,但我收到了另一个错误。但后来我在correct path里发现了另一个。因此,每个typed_config值都应该是api/envoy/config子路径下的一个定义。

本地速率限制的正确配置如下所示。

代码语言:javascript
复制
static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.local_ratelimit
        typed_config:
          "@type": type.googleapis.com/envoy.config.filter.network.local_rate_limit.v2alpha.LocalRateLimit
          stat_prefix: local_rate_limiter
          token_bucket:
            max_tokens: 1000
            tokens_per_fill: 100
            fill_interval: 
              seconds: 1
      - name: envoy.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
...
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63010251

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档