# yue-open-devops-deploy **Repository Path**: yue-open/yue-open-devops-deploy ## Basic Information - **Project Name**: yue-open-devops-deploy - **Description**: 提供Rancher持续部署能力,通知Rancher进行工作负载重新部署(用于docker镜像版本更新后,在Pod配置不变的情况下,更新拉取最新的镜像(或指定版本))。 yue-open-devops-deploy基于yue-library开发,所有配置项皆可通过docker环境变量注入 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2022-01-13 - **Last Updated**: 2025-06-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

提供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 url |`jdbc:mysql://localhost:3306/yue_open_devops_deploy?characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true` | |`spring.datasource.druid.username` |是 |mysql username |`root` | |`spring.datasource.druid.password` |是 |mysql password |`b9a24bc279994963a7789ea802367e17` | yml配置示例: ```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](https://hub.docker.com/r/ylyue/yue-open-devops-deploy) - 国内镜像加速地址:`registry.cn-hangzhou.aliyuncs.com/yl-yue/yue-open-devops-deploy` - 国外镜像加速地址:`registry.cn-hongkong.aliyuncs.com/yue-open/yue-open-devops-deploy` docker启动命令示例(注意替换`-e`环境变量中的值): ```docker 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/` 替换规则变量详解: |变量 |说明 |示例 | |-- |-- |-- | |`rancherUrl` |Rancher 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 | 完整请求示例: ```shell curl -X PUT http://localhost:9999/devops/cd -d 'namespace=test&workloadName=service-user&imageTag=2.0.1' ``` 环境变量请求示例(如:云效等场景): ```shell 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接口传参 - 优化环境变量参数命名 - 重构文档与示例 ### 历史推荐版本 - [2.0.0](https://gitee.com/yue-open/yue-open-devops-deploy/tree/master/docs) - [1.2.0](https://gitee.com/yue-open/yue-open-devops-deploy/tree/master/docs)