[Agent][Deploy] - cmii deploy template rearrange

This commit is contained in:
zeaslity
2024-06-18 09:52:28 +08:00
parent 51fbb2027d
commit 6b2dc33a34
46 changed files with 12655 additions and 13960 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
@@ -11,16 +12,16 @@ import (
"wdd.io/agent-operator/image"
)
func CmiiEnvDeploy() {
func CmiiEnvDeploy(shouldDoCompleteDeploy bool) {
// 部署的环境
cmiiNamespace := dev
// 完整部署
shouldDoCompleteDeploy := true
//shouldDoCompleteDeploy := false
// 输出特定版本的Tag 或者 从DEMO环境拉取
DeploySpecificTag := "5.5.0"
DeploySpecificTag := "5.6.0"
folderPrefix := "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/" + cmiiNamespace + "/"
@@ -58,6 +59,8 @@ func CmiiEnvDeploy() {
utils.BeautifulPrintWithTitle(frontendMap, "frontendMap")
utils.BeautifulPrintWithTitle(srsMap, "srsMap")
common.GenerateApplyFilePath()
// generate and get all old stuff
agent_deploy.CmiiEnvironmentDeploy(shouldDoCompleteDeploy, common, backendMap, frontendMap)
@@ -65,11 +68,15 @@ func CmiiEnvDeploy() {
//GetNodeWideByKubectl(cmiiNamespace)
// clear old apply file
//clearOldApplyStuff(applyYamlFolder+"old/", cmiiNamespace)
//clearOldApplyStuff(common, shouldDoCompleteDeploy)
// apply new app
//applyNewAppStuff(common, shouldDoCompleteDeploy)
fmt.Println()
fmt.Println("-------------------- all done ---------------------")
fmt.Println()
}
func applyNewAppStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDeploy bool) bool {
@@ -87,6 +94,9 @@ func applyNewAppStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDep
if shouldDoCompleteDeploy {
// pvc
ApplyByKubectl(z_dep.PVCApplyFilePath, namespace)
// mysql
ApplyByKubectl(z_dep.MySQLApplyFilePath, namespace)
if !DefaultCmiiOperator.PodStatusCheckTimeout("helm-mysql-0", namespace, 180) {
@@ -133,21 +143,44 @@ func applyNewAppStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDep
return true
}
func clearOldApplyStuff(oldApplyYamlFolder string, cmiiEnv string) bool {
func clearOldApplyStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDeploy bool) bool {
files, err := os.ReadDir(oldApplyYamlFolder)
oldApplyFilePath := filepath.Join(common.ApplyFilePrefix, "old")
files, err := os.ReadDir(oldApplyFilePath)
if err != nil {
log.ErrorF("failed to read directory: %v", err)
return false
}
if len(files) == 0 {
log.WarnF("no apply file found in %s", common.ApplyFilePrefix)
return false
}
// rearrange
//rearrangeCmiiDeploySequence(files)
namespace := common.Namespace
for _, file := range files {
if filepath.Ext(file.Name()) == ".yaml" || filepath.Ext(file.Name()) == ".yml" {
filePath := filepath.Join(oldApplyYamlFolder, file.Name())
DeleteByKubectl(filePath, cmiiEnv)
for _, fileEntry := range files {
switch fileEntry.Name() {
case z_dep.PVCApplyFileName:
continue
case z_dep.MySQLApplyFileName:
continue
case z_dep.MongoApplyFileName:
continue
case z_dep.RedisApplyFileName:
continue
case z_dep.RabbitMQApplyFileName:
continue
case z_dep.EmqxApplyFileName:
continue
case z_dep.NacosApplyFileName:
continue
case z_dep.ConfigMapApplyFileName:
continue
case z_dep.IngresApplyFileName:
continue
default:
log.InfoF("[clearOldApplyStuff] - delete %s", fileEntry.Name())
DeleteByKubectl(filepath.Join(oldApplyFilePath, fileEntry.Name()), namespace)
}
}