j9九游会登录/ 应用平台 appstage/ / / / / 灰度服务配置
更新时间:2025-05-21 gmt 08:00

灰度服务配置-j9九游会登录

本章介绍通过iac进行灰度服务配置的管理,包括灰度规则的管理及灰度阶段切换。对应的资源类型为wisecloud::loadbalancer::grayconfig。

灰度比例转换为pod个数是通过向下取整法,例如:共6个pod,如果灰度比例配置为10%,灰度pod个数则为6 * 0.1 = 0.6,向下取整 = 0,但是必须保持1个的副本数,所以仍要置为1;如果灰度比例配置为20%,灰度pod个数则为6 * 0.2 = 1.2,向下取整 = 1。

使用限制

  • 如果灰度集群(bindslb.graystatus配置为2)想要使用多阶段灰度升级,要求bindslb.graystatus在灰度期间保持配置为2。
  • 首次部署时不要配置graystage,因为要进行灰度升级首先要保证有一个正常运行的版本作为生产,而如果首次部署是满足不了这个条件的,所以要至少正确部署过一次之后才能进行灰度升级。
  • 配置了grayinstances即代表要进入多阶段灰度升级,且百分比只能配置为1%~100%(字符串);但是如果第一阶段就直接配置为100%,则仍然执行普通升级模式。
  • 灰度升级期间(包括进入灰度时),iac配置中不允许修改graystage.graystatus、min_instances、max_instances和slb相关配置,其他配置可以修改。
  • 灰度升级过程中,如果grayinstances的比例达到了100%,grayprocess为ingray时,再进行比例缩小时,该场景只允许修改灰度比例。
  • 灰度升级过程中,如果发现灰度版本配置错误,可以修改iac配置将灰度集群进行重新部署,但是这时不允许修改grayinstances,即iac配置和灰度比例只能修改其中一个。
  • 多阶段灰度升级中,业务将grayinstances配置为100%(未配置grayprocess字段)或grayinstances配置为100%、grayprocess为finished并部署成功后,才算灰度结束了;中间一个阶段部署成功了不算结束灰度,只算这一阶段部署成功了,此时仍然算在灰度升级过程中。
  • 灰度过程中,不允许业务再执行普通部署,不允许在管理台上修改配置,只能通过iac部署修改。
  • 多阶段灰度升级和滚动升级同时使用时,maxunavailable值必须配为0。

配置字段说明

灰度服务类型如表1所示,灰度服务配置字段说明请参见表2,各类型灰度路由引擎配置样例请参见配置样例,灰度升级配置demo请参见灰度升级配置demo

表1 灰度服务类型说明

灰度路由引擎

对应ruletype

slb(>1.3.11)

slb

微服务

microservice

dmq

dmq

分布式job

job

函数

function

表2 灰度服务配置字段说明

参数名

类型

是否必选

说明

ruletype

string

类型:slb、microservice、job、dmq、function。

currentstage

int

当前阶段,1=

currentstatus

string

当前状态,取值为processing、pause、complete,默认为complete。

functionname

string

ruletype为function时必填,否则无效,长度<=200。

functionaliasname

string

ruletype为function时必填,否则无效,长度<=255。

functionaliasname别名不能重复,一个别名只能有一条记录。

routeflag

string

取值为default/special,默认为default。

stages

list<graystage>

灰度阶段

表3 graystage

参数名

类型

是否必选

说明

stageindex

int

阶段编号,最好按照顺序填写1 , 2 , 3 , 4… ,缺省为0 ,后台会排序后,按顺序赋值为1.2.3.4….。

greyrulerelation

string

取值为or或and

routetype为slb时必选,不为slb时无效。

rules

list<grayrule>

routetype为slb时必选,不为slb时无效。

grouprelation

string

取值为or或and

routetype不为slb时必选,为slb时无效。

userextendedparameter

string

routetype为job时有意义,非必选,不为job时无效,必须是json字符串格式。

groups

list<grayrulegroup>

routetype为非slb时必选,为slb时无效。

表4 grayrule

参数名

类型

是否必选

说明

param

string

参数名variable为percent时可以为空,否则不能为空,长度<=50。

  • position为header 时, [a-za-z0-9_\-]
  • position不为header且ruletype不为function时, [.a-za-z0-9_\-]
  • position不为header且ruletype为function时, [.a-za-z0-9_\-\[\]]

variable

string

  • ruletype为slb时,传输类型:"province"、"city"、"countryarea"、"custom"、"advance"、"path"、"client-ip"、"real-ip"
  • ruletype非slb时,传输类型: "province"、"city"、"countryarea"、"custom"、"percent"、"client-ip"、"real-ip"

position

string

位置

  • ruletype非slb时,不传
  • variable为 "client-ip"、"real-ip" 时,为 "na"
  • variable为其他时,为"url"、"body-json"、"body-form"、"header"、"locale"、"resource"、"localecountryarea"、"na"、"path"、"percent"

match

string

匹配方法

  • ruletype为slb时: "pattern"、"sha256"、"equal"、"rangeip"、"locatein"、"tailequal"、"locateincountryarea"、"na"
  • ruletype非slb时: "pattern"、"sha256"、"equal"、"rangeip"、"locatein"、"tailequal"、"locateincountryarea"、"na"、"gt"、"ge"、"lt"、"le"、"notequal"、"percent"
  • variable为 "client-ip"、"real-ip" 时,为 "sha256"、"rangeip"
  • variable为 " path " 时,为 "pattern"、"equal"

values

string

匹配值列表,多个值逗号分隔

  • match为 "tailequal" 时,每个长度小于4
  • match为 " rangeip " 时,样例xx.xx.xx.x-xx.xx.xx.xx
表5 grayrulegroup

参数名

类型

是否必选

说明

groupindex

int

建议按照顺序填写0,1,2,3,4…

不写默认从0开始排序,按顺序赋值为0,1,2,3,4….。

greyrulerelation

string

取值为and或or

microserviceversion

string

微服务版本号,microserviceversion和useinstanceproperty二选一。

function类型可以两个都不选,dmq类型只支持版本号。

如果配置组之间关系为与,各个配置组的版本号相同。

长度<=50

useinstanceproperty

string

微服务自定义灰度参数,microserviceversion和useinstanceproperty二选一。

function类型可以两个都不选,dmq类型只支持版本号。

长度<=50

rules

list<grayrule>

灰度规则列表

配置样例

slb类型样例:

- name: clf_iac3.0_example_gray_slb            // name type唯一定位到一个灰度服务资源
  type: 'wisecloud::loadbalancer::grayconfig'  //资源类型为灰度服务配置
  properties:
    ruletype: slb
    stages:
      - stageindex: 1
        rules:
          - param: path
            values: '5555'
            match: equal
            variable: path
            position: path
        greyrulerelation: or

微服务类型样例:

- name: clf_iac3.0_example_gray_microservice
  type: 'wisecloud::loadbalancer::grayconfig'
  properties:
    currentstatus: processing
    ruletype: microservice
    stages:
      - stageindex: 1
        grouprelation: or
        groups:
          - microserviceversion: latest
            rules:
              - param: aaa
                values: '111'
                match: equal
                variable: custom
            groupindex: 1
            greyrulerelation: or

dmq类型样例:

- name: clf_iac3.0_example_gray_dmq
  type: 'wisecloud::loadbalancer::grayconfig'
  properties:
    ruletype: dmq
    stages:
      - stageindex: 1
        grouprelation: and
        groups:
          - microserviceversion: gray_1
            rules:
              - param: aaa
                values: '2222'
                match: pattern
                variable: custom
              - param: bbb
                values: '1111'
                match: equal
                variable: custom
            groupindex: 1
            greyrulerelation: or

job类型样例:

- name: clf_iac3.0_example_gray_job
  type: 'wisecloud::loadbalancer::grayconfig'
  properties:
    ruletype: job
    stages:
      - stageindex: 1
        grouprelation: or
        groups:
          - microserviceversion: last
            rules:
              - param: ccc
                values: ccc
                match: equal
                variable: custom
                position: ''
            groupindex: 1
            greyrulerelation: or
      - stageindex: 2
        grouprelation: or
        groups:
          - microserviceversion: last
            rules:
              - param: ddd
                values: ddd
                match: tailequal
                variable: custom
            groupindex: 1
            greyrulerelation: or

function类型样例:

- name: clf_iac3.0_example_gray_function
  type: 'wisecloud::loadbalancer::grayconfig'
  properties:
    functionaliasname: >-
      wisefunction:222cn:iot:mcb1fbf087634f199f3a4251c5b8a91e:function:pyd:quanzhong2wisefunction:cn:iot:mcb1fbf087634f199f3a4251c5b8a91e:function:pyd:quanzhong2wisefunction:cn:iot:mcb1fbf087634f199f3a4251c5b8a91e:function:pyd:quanzhong2
    functionname: pyd
    ruletype: function
    stages:
      - stageindex: 1
        grouprelation: or
        groups:
          - rules:
              - param: appid
                values: '123456,22222'
                match: equal
                variable: custom
            groupindex: 1
            greyrulerelation: or

相关文档

网站地图