[agent-operator] - cmii deploy part

This commit is contained in:
zeaslity
2024-06-13 15:06:33 +08:00
parent f1fdfc7777
commit 540d69ede2
19 changed files with 503 additions and 140 deletions

View File

@@ -4,6 +4,7 @@ import (
"os"
image2 "wdd.io/agent-common/image"
"wdd.io/agent-common/logger"
"wdd.io/agent-common/utils"
"wdd.io/agent-deploy/a_dashboard"
"wdd.io/agent-deploy/a_nfs"
"wdd.io/agent-deploy/b_middle"
@@ -166,7 +167,7 @@ func configMapDeploy(common *z_dep.CommonEnvironmentConfig) {
}
// CmiiEnvironmentDeploy 部署完整的CMII环境的所有组件
func CmiiEnvironmentDeploy() {
func CmiiEnvironmentDeploy(isCompleteDeploy bool, cmiiNameSpace string, backendImageVersionMap, frontendImageVersionMap map[string]string) (applyYamlFolder string) {
// common environment
common := &z_dep.CommonEnvironmentConfig{
@@ -174,20 +175,55 @@ func CmiiEnvironmentDeploy() {
WebPort: "",
HarborIP: image2.CmiiHarborPrefix,
HarborPort: "",
Namespace: "devflight",
Namespace: cmiiNameSpace,
TagVersion: "5.5.0",
TenantEnv: "devflight",
TenantEnv: cmiiNameSpace,
}
folderPrefix := "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/"
folderPrefix := "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/" + common.Namespace + "/"
// clear old apply file
_ = os.Mkdir(folderPrefix, os.ModeDir)
oldApplyFileFolder := folderPrefix + "old"
utils.RemoveFolderComplete(oldApplyFileFolder)
_ = os.Mkdir(oldApplyFileFolder, os.ModeDir)
// move all apply file to old folder
_ = utils.FolderMoveFiles(folderPrefix, oldApplyFileFolder)
// clear all middleware data
// ignore redis rabbitmq mongo nacos emqx
// sync mysql-data
z_dep.ApplyFilePrefix = folderPrefix
// generate new apply file for specific environment
if isCompleteDeploy {
// pvc
b_middle.PVCDeploy(common)
// middlewares
b_middle.MidMySQlDeploy(common)
b_middle.MidRedisDeploy(common)
b_middle.MidEmqxDeploy(common)
b_middle.MidMongoDeploy(common)
b_middle.MidRabbitMQDeploy(common)
b_middle.MidNacosDeploy(common)
configMapDeploy(common)
c_app.IngressDeploy(common)
}
// frontend
// frontend
frontendDeploy(common, frontendImageVersionMap)
// backend
backendDeploy(common, backendImageVersionMap)
// apply for them
return folderPrefix
}