此服务为快速构建部署提供支持
原理:获取git push事件,通过k8s api更新服务
-
github webhook 填写接口地址 例如:https://xxx.abc.com/github-event
-
commit格式:deploy:v{版本号}
版本号请参考版本管理( SemVer )
Example:
git commit --allow-empty -am "deploy:v0.0.1"
-
deployment.yaml 添加labels: githubRepoName={github仓库名}
Example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: working
namespace: default
labels:
app: working
githubRepoName: working
...
原理:通过Apollo webhook接收配置更新事件,从k8s api读取apollo关联服务podIP集合,最后广播到每个服务
- 注册ReloadConfigServer(注册了ReloadConfigServer的服务才能主动触发热更新)
import "github.com/comeonjy/go-kit/grpc/reloadconfig"
reloadconfig.RegisterReloadConfigServer(server, reloadconfig.NewServer(conf))
-
deployment.yaml 添加labels: apolloAppId={Apollo配置中心的AppId}
Example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: working
namespace: default
labels:
app: working
apolloAppId: working
...
- 区分不同环境部署