consul-template + shell 实现“灰度”升级

公司服务部署架构:gitlab+jenkins+自己开发的运维管理平台+consul+aws  ec2(cloudformation 进行云资源配置管理)

1、修改/opt/scripts/ServiceManager.sh 添加随机休眠代码
sleep_times=$(($RANDOM%180+60)) 
sleep $sleep_times

注释: 随机休眠时间为 1 到 3分钟之间随机数。

2、创建consul-template 配置文件添加command_timeout参数
template {
source = "/opt/consul/tmptest.ctmpl"
destination = "/opt/consul/tmptest.properties"
command = "/opt/consul/tmptest.sh"
command_timeout = "300s"
}

3、consul-template 启动脚本
consul-template -consul 127.0.0.1:8500 -config "/opt/consul/tmpl.json"

 

posted @ 2019-02-28 18:14  老农夫  阅读(600)  评论(0编辑  收藏  举报