-
Notifications
You must be signed in to change notification settings - Fork 1.4k
如何执行全链路智能编排高级蓝绿灰度发布
HaojunRen edited this page Oct 15, 2022
·
20 revisions
本文档只适用于Discovery 6.16.3及以上版本的集成方式
链路智能编排的方式,即路由链路在后台会智能化编排,用户不再需要关心服务实例的版本情况而进行手工编排,只需要配置跟业务参数有关的条件表达式即可,让蓝绿灰度发布变的更简单更易用
- 线上所有的服务,每个服务实例版本号支持排序,时间戳方式或者数字递增方式都可以
- 线上所有的服务,每个服务至少有一个版本
- 线上所有的服务,每个服务如果有两个版本,第一个划归为旧版本,第二个划归为新版本
- 线上所有的服务,每个服务如果有三个及以上版本,第一个划归为旧版本,第二个到最后划归为新版本。通过逗号分隔的方式放入,例如,
2.0;3.0;4.0
- 线上所有的服务,如果有未接入Nepxion Discovery框架,或者接入了却未设置版本,拉取实例列表的时候,版本默认视作为
default
值,并划归为旧版本
通过向控制台发送请求,控制台根据Json格式规则策略,根据新旧版本的判断,智能编排出两条新旧路由链路,并给它们赋予不同的条件表达式,最终创建出完整的Xml格式规则策略,保存到配置中心
- 创建版本兜底规则策略
Yaml
格式
service:
- discovery-guide-service-a
- discovery-guide-service-b
Json
格式
{
"service": ["discovery-guide-service-a", "discovery-guide-service-b"]
}
经过链路智能编排,等效于
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<strategy>
<version>{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</version>
</strategy>
</rule>
- 创建版本蓝绿规则策略
Yaml
格式
service:
- discovery-guide-service-a
- discovery-guide-service-b
blueGreen:
- expression: "#H['xyz'] == '1'"
route: green
- expression: "#H['xyz'] == '2'"
route: blue
Json
格式
{
"service": ["discovery-guide-service-a", "discovery-guide-service-b"],
"blueGreen": [
{
"expression": "#H['xyz'] == '1'",
"route": "green"
},
{
"expression": "#H['xyz'] == '2'",
"route": "blue"
}
]
}
经过链路智能编排,等效于
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<strategy>
<version>{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</version>
</strategy>
<strategy-release>
<conditions type="blue-green">
<condition id="condition-0" expression="#H['xyz'] == '1'" version-id="route-0"/>
<condition id="condition-1" expression="#H['xyz'] == '2'" version-id="route-1"/>
</conditions>
<routes>
<route id="route-0" type="version">{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</route>
<route id="route-1" type="version">{"discovery-guide-service-a":"1.1","discovery-guide-service-b":"1.1"}</route>
</routes>
</strategy-release>
</rule>
- 创建版本灰度规则策略
Yaml
格式
service:
- discovery-guide-service-a
- discovery-guide-service-b
gray:
- expression: "#H['xyz'] == '3'"
weight:
- 90
- 10
- expression: "#H['xyz'] == '4'"
weight:
- 70
- 30
- weight:
- 100
- 0
Json
格式
{
"service": ["discovery-guide-service-a", "discovery-guide-service-b"],
"gray": [
{
"expression": "#H['xyz'] == '3'",
"weight": [90, 10]
},
{
"expression": "#H['xyz'] == '4'",
"weight": [70, 30]
},
{
"weight": [100, 0]
}
]
}
经过链路智能编排,等效于
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<strategy>
<version>{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</version>
</strategy>
<strategy-release>
<conditions type="gray">
<condition id="condition-0" expression="#H['xyz'] == '3'" version-id="route-0=90;route-1=10"/>
<condition id="condition-1" expression="#H['xyz'] == '4'" version-id="route-0=70;route-1=30"/>
<condition id="condition-2" version-id="route-0=100;route-1=0"/>
</conditions>
<routes>
<route id="route-0" type="version">{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</route>
<route id="route-1" type="version">{"discovery-guide-service-a":"1.1","discovery-guide-service-b":"1.1"}</route>
</routes>
</strategy-release>
</rule>
- 创建版本混合蓝绿灰度 + 内置Header规则策略
Yaml
格式
service:
- discovery-guide-service-a
- discovery-guide-service-b
blueGreen:
- expression: "#H['xyz'] == '1'"
route: green
- expression: "#H['xyz'] == '2'"
route: blue
gray:
- expression: "#H['xyz'] == '3'"
weight:
- 90
- 10
- expression: "#H['xyz'] == '4'"
weight:
- 70
- 30
- weight:
- 100
- 0
header:
xyz: 1
Json
格式
使用时候,请删除中文注释,否则会报错
{
"service": ["discovery-guide-service-a", "discovery-guide-service-b"],
"blueGreen": [
{
"expression": "#H['xyz'] == '1'",
// 绿(旧版本)路由链路
"route": "green"
},
{
"expression": "#H['xyz'] == '2'",
// 蓝(新版本)路由链路
"route": "blue"
}
],
"gray": [
{
"expression": "#H['xyz'] == '3'",
// 稳定(旧版本)路由链路权重,灰度(新版本)路由链路权重
"weight": [90, 10]
},
{
"expression": "#H['xyz'] == '4'",
"weight": [70, 30]
},
{
"weight": [100, 0]
}
],
"header": {"xyz": "1"}
}
经过链路智能编排,等效于
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<strategy>
<version>{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</version>
</strategy>
<strategy-release>
<conditions type="blue-green">
<condition id="condition-0" expression="#H['xyz'] == '1'" version-id="route-0"/>
<condition id="condition-1" expression="#H['xyz'] == '2'" version-id="route-1"/>
</conditions>
<conditions type="gray">
<condition id="condition-0" expression="#H['xyz'] == '3'" version-id="route-0=10;route-1=90"/>
<condition id="condition-1" expression="#H['xyz'] == '4'" version-id="route-0=40;route-1=60"/>
<condition id="condition-2" version-id="route-0=0;route-1=100"/>
</conditions>
<routes>
<route id="route-0" type="version">{"discovery-guide-service-a":"1.0","discovery-guide-service-b":"1.0"}</route>
<route id="route-1" type="version">{"discovery-guide-service-a":"1.1","discovery-guide-service-b":"1.1"}</route>
</routes>
<header>{"xyz":"1"}</header>
</strategy-release>
</rule>
环境搭建,请参考
- Github Wiki :如何对接DevOps运维平台实施流量管控 - 对接DevOps运维平台环境搭建
- Gitee Wiki :如何对接DevOps运维平台实施流量管控 - 对接DevOps运维平台环境搭建
具体用法,请参考
- Github Wiki :如何使用DevOps运维平台对接的公共接口 - 策略接口
- Gitee Wiki :如何使用DevOps运维平台对接的公共接口 - 策略接口
2017-2050 ©Nepxion Studio Apache License
- 如何对接Foundation基础平台实施收敛集成
- 如何对接DevOps运维平台实施流量管控
- 如何部署对接DevOps运维平台的控制台
- 如何对接DevOps运维平台执行半自动化蓝绿灰度发布
- 如何使用DevOps运维平台对接的公共接口
- 如何设计全链路智能编排高级蓝绿灰度发布界面
- 如何实现Windows10下GraalVM本地镜像化
- 蓝绿灰度发布
- 流量染色
- 隔离路由
- 故障转移
- 多活单元化
- 限流熔断降级权限
- 网关动态路由
- 可观测监控
- 如何操作配置中心
- 如何理解框架开关配置
- 如何理解规则策略里内容格式配置
- 如何操作网关和服务的蓝绿灰度发布规则策略配置
- 如何操作网关动态路由规则策略配置
- 如何操作Sentinel规则策略配置
- 如何实施规则策略配置和业务配置在配置中心的合并和分离
- 如何理解自动扫描目录
- 如何自定义流量管控
- 如何自定义实现组合式的防护
- 如何自定义高级配置订阅功能
- 如何自定义订阅框架事件
- 如何自定义解决业务自身跨线程上下文切换的问题
- 如何自定义重用框架内置的Swagger模块
- 如何自定义Header全链路传递
- 如何遵循Nepxion Discovery网关标准实现对其它网关全链路流量管控的二次开发
- 如何遵循Nepxion Discovery服务标准实现对消息队列等其它中间件全链路流量管控的二次开发