[ 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",
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
112
server/src/main/java/io/wdd/func/auto/beans/AppFunctionEnum.java
Normal file
112
server/src/main/java/io/wdd/func/auto/beans/AppFunctionEnum.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package io.wdd.func.auto.beans;
|
||||
|
||||
public enum AppFunctionEnum {
|
||||
|
||||
DEPLOY_RKE(
|
||||
"DEPLOY_RKE",
|
||||
"部署rke的组件,准备环境"
|
||||
),
|
||||
|
||||
DEPLOY_K8S_DASHBOARD(
|
||||
"DEPLOY_K8S_DASHBOARD",
|
||||
"部署kubernetes dashboard"
|
||||
),
|
||||
|
||||
DEPLOY_MINIO(
|
||||
"DEPLOY_MINIO",
|
||||
"部署MINIO, 参数A1C2IP"
|
||||
),
|
||||
|
||||
DEPLOY_NFS(
|
||||
"DEPLOY_NFS",
|
||||
"部署nfs+storage_class, 参数为N1C2IP"
|
||||
),
|
||||
|
||||
|
||||
DEPLOY_STORAGE_CLASS(
|
||||
"DEPLOY_STORAGE_CLASS",
|
||||
"无"
|
||||
),
|
||||
|
||||
DEPLOY_K8S_PVC(
|
||||
"DEPLOY_K8S_PVC",
|
||||
"部署所需要的pvc后端存储,参数 SUPREME"
|
||||
),
|
||||
|
||||
DEPLOY_K8S_MYSQL(
|
||||
"DEPLOY_K8S_MYSQL",
|
||||
"部署k8s mysql, 参数 SUPREME, A1C2IP"
|
||||
),
|
||||
|
||||
LOAD_MYSQL_INIT_SCRIPT(
|
||||
"LOAD_MYSQL_INIT_SCRIPT",
|
||||
"加载MySQl的初始化脚本,"
|
||||
),
|
||||
|
||||
DEPLOY_K8S_REDIS(
|
||||
"DEPLOY_K8S_REDIS",
|
||||
"部署k8s redis, 参数 SUPREME, A1C2IP "
|
||||
),
|
||||
|
||||
DEPLOY_K8S_MIDDLEWARES(
|
||||
"DEPLOY_K8S_MIDDLEWARES",
|
||||
"部署k8s mongo nacos emqxs, 参数 SUPREME, A1C2IP "
|
||||
),
|
||||
|
||||
INIT_MINIO(
|
||||
"INIT_MINIO",
|
||||
"初始化MINIO, c参数SUPREME A1C2IP M2D2IP"
|
||||
),
|
||||
|
||||
DEPLOY_K8S_SRS(
|
||||
"DEPLOY_K8S_SRS",
|
||||
""
|
||||
),
|
||||
|
||||
DEPLOY_GDR(
|
||||
"DEPLOY_GDR",
|
||||
""
|
||||
),
|
||||
|
||||
MODIFY_NACOS(
|
||||
"MODIFY_NACOS",
|
||||
"修改Nacos,手动!"
|
||||
),
|
||||
|
||||
DEPLOY_INGRESS(
|
||||
"DEPLOY_INGRESS",
|
||||
"部署Ingress服务"
|
||||
|
||||
),
|
||||
|
||||
DEPLOY_FRONTEND(
|
||||
"DEPLOY_FRONTEND",
|
||||
"部署前端服务"
|
||||
|
||||
),
|
||||
|
||||
DEPLOY_BACKEND(
|
||||
"DEPLOY_BACKEND",
|
||||
"部署后端服务"
|
||||
|
||||
);
|
||||
|
||||
String appOpName;
|
||||
|
||||
String desc;
|
||||
|
||||
|
||||
AppFunctionEnum(String appOpName, String desc) {
|
||||
this.appOpName = appOpName;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getAppOpname() {
|
||||
return appOpName;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class BaseFuncScheduler {
|
||||
}
|
||||
|
||||
List<BaseFunctionEnum> masterNodeDurationTaskList = List.of(
|
||||
// BaseFunctionEnum.INSTALL_DOCKER,
|
||||
BaseFunctionEnum.INSTALL_DOCKER,
|
||||
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
|
||||
BaseFunctionEnum.INSTALL_HARBOR
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user