17 Star 53 Fork 18

Xiaoyan.Rao / kong-plugins-canary

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Canary金丝雀插件[基于kong]

0. 概述

基于kong[基于1.2.1版本]网关灰度插件

canary插件的使用范围支持global、service、route

1.应用场景

  • 灰度上线、版本迭代(灰度的量灵活切换)

  • 特殊用户、特别版本(灰度的方式多样化)

2. canary插件设计原理

avatar

3. 安装说明

https://luarocks.org/modules/raoxiaoyan/canary-oss

luarocks install lua-resty-iputils
luarocks install canary-oss

启用canary,在/etc/kong/kong.conf增加如下配置:

plugins = bundled,canary-oss

kong restart 重启即可

4. canary配置界面

推荐使用kong可视化管理平台kongx进行管理 avatar

5. 配置参数说明

5.1 canary_upstream

canary_upstream为必填项,设置默认转发的上游代理名称,如下所示:

msgbox.upstream

灰度规则1:ip

range

设置ip支持单个,多个,范围分段IP(满足CIDR notation规则),以下值都为合法

10.0.2.2 
10.0.5.0/2

upstream

非必填项,设置符合ip灰度规则时,转发的上游代理名称

灰度规则2:uid

on

uid的参数从哪里获取;参数所处位置可选为:

header:请求头中获取uid参数

cookie:从cookie中获取uid参数

args:从请求参数中获取uid参数

name

uid在请求中的参数名

range

设置uid的匹配规则,支持单个,多个,正则匹配(前缀、后缀等)

1234
^UID%d+$ //匹配前缀

upstream

非必填项,设置符合uid灰度规则时,转发的上游代理名称

灰度规则3:customize

自定义规则

on

自定义的参数从哪里获取;参数所处位置可选为:

header:请求头中获取uid参数

cookie:从cookie中获取uid参数

args:从请求参数中获取uid参数

name

请求中的参数名,例如:region(地域)

range

设置匹配规则,支持单个,多个,正则匹配(前缀、后缀等)

SD001
^BJ%d+$ //匹配前缀

upstream

非必填项,设置符合该灰度规则时,转发的上游代理名称

规则优先级

默认情况下,未设置任何灰度规则时,默认灰度规则生效

优先级如下:

ip > uid > customize > default

MIT License Copyright (c) 2020 raoxiaoyan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于网关kong灰度插件,称之为金丝雀,满足A/B测试、动态切换上游代理 展开 收起
Lua
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Lua
1
https://gitee.com/raoxy/kong-plugins-canary.git
git@gitee.com:raoxy/kong-plugins-canary.git
raoxy
kong-plugins-canary
kong-plugins-canary
master

搜索帮助

14c37bed 8189591 565d56ea 8189591