其他分享
首页 > 其他分享> > Envoy 流量迁移

Envoy 流量迁移

作者:互联网

流量迁移

流量迁移配置格式

---
  routes:
  - match: # 定义路由匹配参数;
    prefix|path|regex: ... # 流量过滤条件,三者必须定义其中之一;
    runtime_fraction: # 额外匹配指定的运行时键值,每次评估匹配路径时,它必需低于此字段指示的匹配百分比;支持渐进式修改;
      default_value: # 运行时键值不可用时,则使用此默认值;
        numerator: # 指定分子,默认为0;
        denominator: # 指定分母,小于分子时,最终百分比为1;分母可固定使用HUNDRED(默认)、TEN_THOUSAND和MILLION;
      runtime_key: routing.traffic_shift.KEY # 指定要使用的运行时键,其值需要用户自定义;
    route:
      custer: app1_v1
  - match:
    prefix|path|regex: ... # 此处的匹配条件应该与前一个路由匹配条件相同,以确保能够分割流量;
    route:
      cluster: app1_v2 # 此处的集群通常是前一个路由项目中的目标集群应用程序的不同版本;

流量迁移配置示例

admin:
  profile_path: /tmp/envoy.prof
  access_log_path: /tmp/admin_access.log
  address:
    socket_address:
       address: 0.0.0.0
       port_value: 9901

layered_runtime:
  layers:
  - name: admin
    admin_layer: {}
       
static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0, port_value: 80 }
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          codec_type: AUTO
          route_config:
            name: local_route
            virtual_hosts:
            - name: demoapp
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                  runtime_fraction:
                    default_value:
                      numerator: 100
                      denominator: HUNDRED
                    runtime_key: routing.traffic_shift.demoapp
                route:
                  cluster: demoappv10
              - match:
                  prefix: "/"
                route:
                  cluster: demoappv11
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

  clusters:
  - name: demoappv10
    connect_timeout: 0.25s
    type: STRICT_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: demoappv10
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: demoappv10
                port_value: 80

  - name: demoappv11
    connect_timeout: 0.25s
    type: STRICT_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: demoappv11
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: demoappv11
                port_value: 80

动态调整流量分发比例

# 将保留给demoappv10集群的流量比例调整为90%,方法是将指定键的值定义为相应的分子数即可
curl -XPOST http://envoy_ip:9901/runtime_modify?routing.traffic_shift.demoapp=90

 

标签:name,envoy,Envoy,流量,address,迁移,runtime,路由
来源: https://www.cnblogs.com/wangguishe/p/16658601.html