关于灰度发布:kong安装部署含Canary

1.装置kong

## centos7 参考 https://docs.konghq.com/install/centos/
## 下载包,如果环境没联网,能够通过本地下载好上传至服务器
wget https://bintray.com/kong/kong-rpm/download_file?file_path=centos/7/kong-2.3.0.el7.amd64.rpm
sudo yum install /path/to/kong-2.3.0.el7.amd64.rpm --nogpgcheck

## ubuntu 参考 https://docs.konghq.com/install/ubuntu/
## 下载包,如果环境没联网,能够通过本地下载好上传至服务器
wget https://bintray.com/kong/kong-deb/download_file?file_path=kong-2.3.0.bionic.amd64.deb
sudo apt-get update
sudo apt-get install /absolute/path/to/kong-2.3.0.bionic.amd64.deb

2.装置插件 canary

2.1. 在线装置

## 在线装置 lua-resty-iputils
luarocks install lua-resty-iputils

## 在线装置 canary
luarocks install canary

2.2. 离线装置

在有网的中央下载好源码文件

## 提前下载并重命名为 lua-resty-iputils-0.3.0.zip
wget https://github.com/hamishforbes/lua-resty-iputils/archive/v0.3.0.zip

## 拜访 https://github.com/raoxiaoyan/kong-plugins-canary 下载源码 kong-plugins-canary-master.zip

## 下载最新的 canary-1.0.4-1.rockspec,因为源码我的项目没有
wget https://luarocks.org/manifests/raoxiaoyan/canary-1.0.4-1.rockspec

将 lua-resty-iputils-0.3.0.zip , kong-plugins-canary-master.zip , canary-1.0.4-1.rockspec 上传至指定服务器

## 解压 lua-resty-iputils-0.3.0.zip
unzip lua-resty-iputils-0.3.0.zip
cd lua-resty-iputils-0.3.0
## 装置
luarocks make lua-resty-iputils-0.3.0-1.rockspec

## 解压kong-plugins-canary-master.zip
unzip kong-plugins-canary-master.zip
cd kong-plugins-canary-master
## 将之前下载的 canary-1.0.4-1.rockspec 放到当前目录下
cp canary-1.0.4-1.rockspec .
## 装置
luarocks make canary-1.0.4-1.rockspec

3.配置kong

kong启动是会读取/etc/kong/kong.conf文件,配置文件内容具体如下:
装置cassandra集群

log_level = notice
plugins = bundled,canary
proxy_listen = 0.0.0.0:8000
#  依据理论状况批改
admin_listen = 127.0.0.2:8001
database = cassandra
cassandra_contact_points = 127.0.0.1,127.0.0.2
#依据理论状况批改
cassandra_port = 9042
db_update_propagation = 5
cassandra_repl_strategy = SimpleStrategy
cassandra_repl_factor = 2
#异步从Cassandra更新配置
worker_consistency = eventual
#nginx最大body size 20m
nginx_http_client_max_body_size = 20m

配置好/etc/kong/kong.conf文件,需执行以下命令:

## 初始化数据库
sudo kong migrations bootstrap

## 启动kong
sudo kong start

## 如果启动胜利,可胜利调用admin的api申请
curl -i http://localhost:8001/

4.启动kong

sudo cp /etc/kong/kong.conf.default /etc/kong/kong.conf

## 批改数据库为 cassandra
sudo vi kong.conf
database = cassandra

## 初始化数据库
sudo kong migrations bootstrap

## 启动kong
sudo kong start

## 如果启动胜利,可胜利调用admin的api申请
curl -i http://127.0.0.2:8001/

5.装置治理平台konga

5.1. 在线装置

kong提供了丰盛的admin api 接口,为了不便的调用这些接口,装置konga来治理。

git clone https://github.com/pantsel/konga.git
cd konga
## 装置依赖包
npm i
## 后盾启动
nohup npm start &

拜访 http://localhost:1337

5.2. 离线装置

离线装置的形式是在与指标服务器雷同操作系统的服务器上,执行在线装置,而后将konga整个文件夹打包成konga-master-package.zip,传到指标服务器。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理