更新时间:2024-05-24 GMT+08:00
分享

转发策略配置

本章介绍通过IaC进行转发策略配置的管理,包括监听下的转发策略、健康检查、后端服务器及动态路由管理。对应的资源类型为WiseCloud::LoadBalancer::SLB::RouteRule。

表1 转发策略配置字段说明

参数名

是否必选

说明

listenerGroupName

SLB监听名称,一个转发策略实例只能绑定一个监听实例。

targetGroups

后端集群

routes

转发策略(Locations)

dynamicRoutes

动态路由

表2 targetGroups字段说明

参数名

是否必选

说明

name

后端集群名,不超过150位,不包含特殊字符。

protocol

协议,取值为:HTTP或HTTPS。

loadBalancer

后端集群负载均衡类型

healthCheck

健康检查

表3 loadBalancer字段说明

参数名

是否必选

说明

strategy

负载均衡算法,支持"roundRobin"、"protocolParam"、"IP_HASH"、"least_conn"。

slowStartDelay

预热时延,不超过30。

slowStartPeriod

预热周期,不超过30。

slowStartFactor

预热因子,默认为10,不小于1,不超过100。

hashParam

哈希转发字段名,Strategy类型为protocolParam时必填

长度不超过50,由字母加数字,下划线,横杠,点组成。

customParam

自定义参数,不包含by_lua。

默认取第一个后端集群的健康检查配置,如果为空,使用默认值。

表4 healthCheck字段说明

参数名

是否必选

说明

switchStatus

是否开启健康检查,取值为on或off,不填或者其他字符均为off。

protocol

协议,默认HTTP,不可修改。

path

检查路径,长度不超过500,由字母、数字、横杠、下划线和点组成。

successCodes

成功码列表,100-600之间的数字,以逗号隔开。

healthyThreshold

健康阈值,取值范围2-10,默认为2。

interval

探测间隔时间,取值范围1-50,默认为5。

timeout

探测超时时间,取值范围1-300,默认为10。

unhealthyThreshold

不健康阈值,取值范围2-10,默认为3。

表5 RouteRule字段说明

参数名

是否必选

说明

location

转发策略地址,长度不超过500,非中文。

targetGroup

后端集群名,长度不超过150,由字母、数字、下划线、横杠和点组成。

grayServiceName

灰度规则

degradeUrl

降级url

  • 不降级:unDegrade
  • 默认降级:defaultDegrade

只有值为defaultDegrade时才为默认降级,其他值均认为是不降级。

configs

通用与高级配置

表6 dynamicRoutes字段说明

参数名

是否必选

说明

name

名称,长度不超过50,由字母、数字、下划线、横杠和点组成,不能包含-in-且不能以-in结尾。

switchStatus

开关,取值为on或off。

defaultTargetGroup

默认后端集群

enableGrey

默认后端集群是否仍参考灰度进行分流,取值为on/off,默认为off,只有输入on才为打开状态。

rules

动态路由规则

locations

动态路由关联的转发策略列表。

表7 rules字段说明

参数名

是否必选

说明

condition

名称

targetGroup

后端集群

enableGray

是否仍参考灰度进行分流,取值为on或off,默认为off,只有输入on才为打开状态。

转发策略模板yaml

- name: hw_test                                  // 必填项,不可修改,不可重复
  type: WiseCloud::LoadBalancer::SLB::RouteRule  // 资源类型为转发策略配置
  properties:
    routes:                                     // 非必填
      - targetGroup: group1
        grayServiceName: grayServce_hw
        location: /abc_hw1
        degradeUrl: unDegrade                  // 必填项,unDegrade不降级,defaultDegrade默认降级
        configs:
          hostSwitch: 'off'
          addHeaders:
            - value: b
              key: aaa
          clientConnectionFreeTime: 60
          rewrites:
            - source: /test
              option: break
              target: /test_hw
          proxyReadTimeout: 60
          setVals:
            - value: bbb
              key: aaa
          keepaliveSwitch: 'off'
          proxyBuffersSize: 2 m
          expiresSwitch: 'on'
          proxyBuffersSwitch: 'on'
          accessLogSwitch: 'on'
          clientMaxBodySize: 3 k
          clientBodyBufferSize: 2 k
          expiresSize: 2 m
          proxyNextUpstreamCondition: 'error,timeout'
          proxySendTimeout: 60
          xForwardedForSwitch: 'off'
          proxyNextUpstreamSwitch: 'on'
          allowMethod: 'POST,PUT,DELETE'
    targetGroups:                                // 非必填
      - protocol: HTTP                           // 必填项
        loadBalancer:                            // 必填项,负载均衡类型
          strategy: roundRobin                   // 必填项,负载均衡策略
        healthCheck:                             // 非必填,健康检查
          path: /abc_test
          protocol: HTTP                         // 固定项
          successCodes: '200,302'
          healthyThreshold: '2'
          unhealthyThreshold: '3'
          switchStatus: 'on'                     // 默认关闭,on为打开,打开时,不传其他参数均使用默认值
        name: group1                             // 必填项,并且不可重复,长度不超过150,不包含特殊字符
      - protocol: HTTP
        loadBalancer:
          hashParam: $xxx
          strategy: protocolParam
          customParam: $xxx
        healthCheck:
          switchStatus: 'off'
        name: group2
    listenerGroupName: zwx_listener1             // 必填项,SLB监听名称,一个转发策略实例只能绑定一个监听实例
    dynamicRoutes:                               // 非必填
      - enableGrey: 'off'
        defaultTargetGroup: group1               // 必填并且存在于targetGroups中
        name: /abc_test1_hw
        locations:
          - location: /abc_hw1
        rules:
          - targetGroup: group1
            enableGray: 'off'
        switchStatus: 'on'
分享:

    相关文档

    相关产品