[ Agent ] [ APP ] - refresh app procedure
This commit is contained in:
@@ -23,10 +23,16 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
var result []string
|
||||
|
||||
switch appFuncName {
|
||||
case "deployMinio":
|
||||
case "DEPLOY_RKE":
|
||||
resultOK, result = op.deployRke(funcArgs)
|
||||
break
|
||||
case "DEPLOY_K8S_DASHBOARD":
|
||||
resultOK, result = op.deployK8sDashboard(funcArgs)
|
||||
break
|
||||
case "DEPLOY_MINIO":
|
||||
resultOK, result = op.deployMinio(funcArgs)
|
||||
break
|
||||
case "deployNFS":
|
||||
case "DEPLOY_NFS":
|
||||
resultOK, result = op.deployNFS(funcArgs)
|
||||
break
|
||||
case "testNFS":
|
||||
@@ -35,39 +41,42 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
case "deployPVC":
|
||||
resultOK, result = op.deployPVC(funcArgs)
|
||||
break
|
||||
case "deploySC":
|
||||
case "DEPLOY_STORAGE_CLASS":
|
||||
break
|
||||
case "deployMySQL":
|
||||
case "DEPLOY_K8S_MYSQL":
|
||||
resultOK, result = op.deployMySQL(funcArgs)
|
||||
break
|
||||
case "LOAD_MYSQL_INIT_SCRIPT":
|
||||
resultOK, result = op.loadMysqlInitScript(funcArgs)
|
||||
break
|
||||
case "checkMySQL":
|
||||
resultOK, result = op.checkMySQL(funcArgs)
|
||||
break
|
||||
case "deployMiddlewares":
|
||||
case "DEPLOY_K8S_MIDDLEWARES":
|
||||
resultOK, result = op.deployMiddlewares(funcArgs)
|
||||
break
|
||||
case "deployRedis":
|
||||
case "DEPLOY_K8S_REDIS":
|
||||
resultOK, result = op.deployRedis(funcArgs)
|
||||
break
|
||||
case "deployIngress":
|
||||
case "DEPLOY_INGRESS":
|
||||
resultOK, result = op.deployIngress(funcArgs)
|
||||
break
|
||||
case "deployFront":
|
||||
case "DEPLOY_FRONTEND":
|
||||
resultOK, result = op.deployFront(funcArgs)
|
||||
break
|
||||
case "initMinio":
|
||||
case "INIT_MINIO":
|
||||
resultOK, result = op.initMinio(funcArgs)
|
||||
break
|
||||
case "deploySRS":
|
||||
case "DEPLOY_K8S_SRS":
|
||||
resultOK, result = op.deploySRS(funcArgs)
|
||||
break
|
||||
case "deployGDR":
|
||||
resultOK, result = op.deployGDR(funcArgs)
|
||||
break
|
||||
case "modifyNacos":
|
||||
case "MODIFY_NACOS":
|
||||
resultOK, result = op.modifyNacos(funcArgs)
|
||||
break
|
||||
case "deployBackend":
|
||||
case "DEPLOY_BACKEND":
|
||||
resultOK, result = op.deployBackend(funcArgs)
|
||||
break
|
||||
default:
|
||||
@@ -80,6 +89,35 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
return resultOK, result
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployRke(funcArgs []string) (bool, []string) {
|
||||
|
||||
var ok bool
|
||||
var resultLog []string
|
||||
// download rke
|
||||
// download kubectl
|
||||
// download rke-cluster.yml
|
||||
ok, resultLog = BasicDownloadFile(op.OssOfflinePrefix+"rke", "/usr/local/bin/rke")
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
ok, resultLog = BasicDownloadFile(op.OssOfflinePrefix+"kubectl", "/usr/local/bin/kubectl")
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
ok, resultLog = BasicDownloadFile(op.OssOfflinePrefix+"rke-cluster-template.yaml", "/root/wdd/rke-cluster.yml")
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
|
||||
return true, []string{
|
||||
"[deployRke] - rke dependency download success !",
|
||||
}
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployK8sDashboard(funcArgs []string) (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployMinio(funcArgs []string) (bool, []string) {
|
||||
minioTemplateFileName := "minio-docker-compose.yaml"
|
||||
result := append(AppExecuteErrorLogPrefix, "部署MINIO")
|
||||
@@ -335,6 +373,10 @@ func (op *AgentOsOperator) deployMySQL(funcArgs []string) (bool, []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) loadMysqlInitScript(funcArgs []string) (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) checkMySQL(funcArgs []string) (bool, []string) {
|
||||
|
||||
// 设置超时时间为 120 秒
|
||||
|
||||
@@ -1073,34 +1073,17 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
|
||||
|
||||
log.Info("[install harbor] - start to modify harbor config file!")
|
||||
|
||||
AllCompleteExecutor([][]string{
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborHostName/" + op.AgentServerInfo.ServerIPInV4 + "/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborHostPort/8033/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"sed",
|
||||
"-i",
|
||||
"s/HarborAdminPas/V2ryStr@ngPss/g",
|
||||
"/root/wdd/harbor/harbor.yml",
|
||||
},
|
||||
{
|
||||
"chmod",
|
||||
"+x",
|
||||
"/root/wdd/harbor/install.sh",
|
||||
},
|
||||
AllCommandExecutor([]string{
|
||||
"chmod",
|
||||
"+x",
|
||||
"/root/wdd/harbor/install.sh",
|
||||
})
|
||||
|
||||
log.InfoF("[install harbor] - harbor config changed success to => %s!", op.AgentServerInfo.ServerIPInV4)
|
||||
BasicReplace("/root/wdd/harbor/harbor.yml", "HarborHostName", op.AgentServerInfo.ServerIPInV4)
|
||||
BasicReplace("/root/wdd/harbor/harbor.yml", "HarborHostPort", "8033")
|
||||
BasicReplace("/root/wdd/harbor/harbor.yml", "HarborAdminPas", "V2ryStr@ngPss")
|
||||
|
||||
log.InfoF("[install harbor] - harbor config changed success to => %s!", op.AgentServerInfo.ServerIPInV4)
|
||||
// install
|
||||
log.Info("[install harbor] - going to start harbor !")
|
||||
executor := ReadTimeCommandExecutor([]string{
|
||||
@@ -1641,13 +1624,13 @@ func (op *AgentOsOperator) openBBRExec() (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) ok(args []string) [][]string {
|
||||
log.InfoF("base function is ok , args are => " + strings.Join(args, " "))
|
||||
func (op *AgentOsOperator) ok(funcArgs []string) [][]string {
|
||||
log.InfoF("base function is ok , args are => " + strings.Join(funcArgs, " "))
|
||||
return [][]string{
|
||||
{"ifconfig"},
|
||||
}
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) okExec(args []string) (bool, []string) {
|
||||
func (op *AgentOsOperator) okExec(funcArgs []string) (bool, []string) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -244,3 +244,57 @@ func BasicConvertBufferToSlice(outputBuffer bytes.Buffer) (resultLog []string) {
|
||||
return split
|
||||
|
||||
}
|
||||
|
||||
// BasicDownloadFile 从目标地址下载文件到目的地,并检测文件是否下载成功
|
||||
func BasicDownloadFile(downloadUrl, desFile string) (downloadOk bool, resultLog []string) {
|
||||
|
||||
// wget or curl download
|
||||
var ok bool
|
||||
if BasicCommandExists("wget") {
|
||||
|
||||
ok, resultLog = AllCommandExecutor([]string{
|
||||
"wget",
|
||||
"--no-check-certificate",
|
||||
"--timeout=5",
|
||||
downloadUrl,
|
||||
"-qO",
|
||||
desFile,
|
||||
})
|
||||
|
||||
} else if BasicCommandExists("curl") {
|
||||
ok, resultLog = AllCommandExecutor([]string{
|
||||
"curl",
|
||||
"-o",
|
||||
desFile,
|
||||
"--insecure",
|
||||
"--max-time",
|
||||
"5",
|
||||
downloadUrl,
|
||||
})
|
||||
|
||||
} else {
|
||||
sprintf := fmt.Sprintf("[BasicDownloadFile] - neither wget or curl exists ! can't download file [ %s ] from [ %s ]", desFile, downloadUrl)
|
||||
log.Error(sprintf)
|
||||
return false, []string{
|
||||
sprintf,
|
||||
}
|
||||
}
|
||||
|
||||
errLog := fmt.Sprintf("[BasicDownloadFile] - download file [ %s ] from [ %s ] failed !", desFile, downloadUrl)
|
||||
if !ok {
|
||||
log.Error(errLog)
|
||||
return false, []string{
|
||||
errLog,
|
||||
}
|
||||
}
|
||||
// check file exists
|
||||
existAndNotNull := BasicFileExistAndNotNull(desFile)
|
||||
if !existAndNotNull {
|
||||
return false, []string{
|
||||
errLog,
|
||||
"[BasicDownloadFile] - file not exist !",
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -404,5 +404,6 @@ func (hOp *HarborOperator) SyncStatusExec(funcArgs []string) (bool, []string) {
|
||||
}
|
||||
|
||||
func (hOp *HarborOperator) Command(baseFuncName string, funcArgs ...string) []string {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ func CheckPodStatus(specific string, supreme string) bool {
|
||||
log.Error("kubectl命令不存在,无法查看Pod状态,请查看!")
|
||||
}
|
||||
|
||||
executor, err := SingleLineCommandExecutor([]string{
|
||||
ok, resultLog := AllCommandExecutor([]string{
|
||||
"kubectl", "-n", supreme, "get", "pod", specific, "-o", "jsonpath='{.status.phase}'",
|
||||
})
|
||||
if err != nil {
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, resultLine := range executor {
|
||||
for _, resultLine := range resultLog {
|
||||
if strings.HasPrefix(resultLine, "Running") {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user