Sign inSign up

ylyue/yue-open-devops-deploy

By ylyue

•Updated over 2 years ago

yue-open Rancher 持续部署

Image
1

752

ylyue/yue-open-devops-deploy repository overview

⁠

提供Rancher持续部署能力

yue-library官网 ⁠ GitHub ⁠ Docker Pulls ⁠ gitee star ⁠ GitHub Repo stars ⁠ GitHub issues ⁠

-- 主页:https://ylyue.cn/⁠ --

-- QQ群:883630899⁠ --


⁠yue-open-devops-deploy

提供Rancher持续部署能力,通知Rancher进行工作负载重新部署(用于docker镜像版本更新后,在Pod配置不变的情况下,更新拉取最新(或指定版本)的镜像)。

yue-open-devops-deploy基于yue-library开发,所有配置项皆可通过docker -e 环境变量注入

⁠docker部署

MySQL8数据库初始化脚本位于docs/mysql8/yue_open_devops_deploy.sql
yue-open-devops-deploy 2.x开始提供admin后台,因此需要依赖MySQL数据库。

  • 暂不提供基于SQLite的方式,考虑一般开发环境都有业务数据库,如果你也恰好是MySQL8,那正好,你只需要在你的MySQL8实例中新建一个名为yue_open_devops_deploy的数据库utf8mb4/utf8mb4_0900_ai_ci字符集,然后再导入yue_open_devops_deploy.sql
⁠配置项说明
配置项
必填
配置项说明
示例配置
server.port否容器内部端口号默认:9999
spring.datasource.druid.url是mysql urljdbc:mysql://localhost:3306/yue_open_devops_deploy?characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
spring.datasource.druid.username是mysql usernameroot
spring.datasource.druid.password是mysql passwordb9a24bc279994963a7789ea802367e17

yml配置示例:

server:
  port: 9999
spring:
  datasource:
    druid:
      url: jdbc:mysql://localhost:3306/yue_open_devops_deploy?characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
      username: root
      password: b9a24bc279994963a7789ea802367e17
⁠docker启动命令示例
  • 👉dockerhub⁠
  • 国内镜像加速地址:registry.cn-hangzhou.aliyuncs.com/yl-yue/yue-open-devops-deploy
  • 国外镜像加速地址:registry.cn-hongkong.aliyuncs.com/yl-yue/yue-open-devops-deploy

docker启动命令示例(注意替换-e环境变量中的值):

docker run -d -e key=value -p9999:9999 --name=yue-open-devops-deploy ylyue/yue-open-devops-deploy:2.8.0

⁠如何使用

⁠第一步

确保 yue-open-devops-deploy 已部署在可访问 Rancher Service API 的环境中(推荐直接部署在Rancher管理的k8s集群中)

⁠第二步

访问 http://xxxxxxxxx:9999⁠ 进入admin界面配置 Rancher API 信息 Rancher API地址、bearerToken值、匹配的命名空间

  • Rancher API地址:见下述文档,用于调用 Rancher API
  • bearerToken值:调用 Rancher API 时需要认证,在 Rancher UI 中创建 API 密钥
  • 匹配的命名空间:此条 Rancher 配置所对应的命名空间(支持多个值,,分割)

Rancher API地址示例:https://192.168.3.52/k8s/clusters/c-m-t8djxmjs/v1/apps.deployments/

替换规则:https://${rancherUrl}/k8s/clusters/${clusterId}/v1/apps.deployments/

替换规则变量详解:

变量说明示例
rancherUrlRancher UI地址(不是默认端口时需要带端口)https://192.168.3.52
clusterId集群ID,在点击对应集群后的地址栏可获得c-m-t8djxmjs
⁠第三步

Jenkins 调用 yue-open-devops-deploy /devops/cd 接口,实现 cd 与通知

HTTP接口地址:PUT /devops/cd

参数名
必填
参数作用说明
参数值示例
namespace是命名空间,Rancher中的命名空间,与上述的Rancher配置匹配test1
workloadName是工作负载,Rancher中命名空间下的工作负载service-user
imageTag否docker镜像版本2.0.1

完整请求示例:

curl -X PUT http://localhost:9999/devops/cd -d 'namespace=test&workloadName=service-user&imageTag=2.0.1'

环境变量请求示例(如:云效等场景):

curl -X PUT ${yoddUrl} -d 'namespace='${namespace}'&workloadName='${workloadName}'&imageTag='${DATETIME}

⁠版本历史

⁠2.8.0
  • 通过配置各环境BearerToken与对应命名空间,简化Rancher CD使用,根据部署请求自动创建工作负载与docker镜像信息
  • 简化使用简化UI,提供部署日志等
⁠2.0.0
  • 提供UI界面管理,更方便的实现CD、回滚、发版到其他环境等
  • 数据存储在数据库中,更方便查看版本与相关信息
  • cd接口参数更加精简,因为数据已存在数据库中
⁠1.2.0
  • 增强bearerToken的兼容性,可识别未带Bearer 前缀的bearerToken
  • 优化钉钉通知,使得无论是成功或错误通知,都更加直观具体
  • 完善workloadApiUrl请求参数详解文档
⁠1.1.1
  • 钉钉通知加入imageTag,方便docker镜像版本追溯
⁠1.1.0

yodd加入yue-open项目集后,正式推出的第一个规范化版本:

  • 优化API接口传参
  • 优化环境变量参数命名
  • 重构文档与示例
⁠历史推荐版本

Tag summary

Content type

Image

Digest

sha256:049aa1a99…

Size

126.2 MB

Last updated

over 2 years ago

docker pull ylyue/yue-open-devops-deploy:2.8.0