[ Agent ] [ APP ] - accomplish rke and dashboard
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -89,6 +90,16 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
||||
return resultOK, result
|
||||
}
|
||||
|
||||
func CheckAppInstallFolder() (bool, []string) {
|
||||
if !BasicCreateFolder("/root/wdd/install") {
|
||||
return false, []string{
|
||||
"[CheckAppInstallFolder] - install folder create failed !",
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployRke(funcArgs []string) (bool, []string) {
|
||||
|
||||
var ok bool
|
||||
@@ -115,6 +126,49 @@ func (op *AgentOsOperator) deployRke(funcArgs []string) (bool, []string) {
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployK8sDashboard(funcArgs []string) (bool, []string) {
|
||||
|
||||
restartHarborExec, strings := op.restartHarborExec()
|
||||
if !restartHarborExec {
|
||||
return false, strings
|
||||
}
|
||||
|
||||
// check folder
|
||||
folder, i := CheckAppInstallFolder()
|
||||
if !folder {
|
||||
return false, i
|
||||
}
|
||||
|
||||
// download template file
|
||||
k8sDashBoardYamlFile := "/root/wdd/install/k8s-dashboard.yaml"
|
||||
ok, resultLog := BasicDownloadFile(op.OssOfflinePrefix+"k8s-dashboard-template.yaml", k8sDashBoardYamlFile)
|
||||
if !ok {
|
||||
return false, resultLog
|
||||
}
|
||||
|
||||
// kubectl
|
||||
|
||||
// replace
|
||||
parseIP := net.ParseIP(funcArgs[0])
|
||||
if parseIP == nil {
|
||||
return false, []string{
|
||||
"[deployK8sDashboard] - ip args error !",
|
||||
}
|
||||
}
|
||||
BasicReplace(k8sDashBoardYamlFile, "A1C2IP", funcArgs[0])
|
||||
|
||||
// up
|
||||
applyExec, resultLog := KubectlApplyExec(k8sDashBoardYamlFile)
|
||||
if !applyExec {
|
||||
return false, resultLog
|
||||
}
|
||||
|
||||
// check deployment ok
|
||||
if !CheckDeploymentStatusTimeout("kubernetes-dashboard", "kube-system", 120) {
|
||||
return false, []string{
|
||||
"[deployK8sDashboard] - deployment run error !",
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -379,27 +433,13 @@ func (op *AgentOsOperator) loadMysqlInitScript(funcArgs []string) (bool, []strin
|
||||
|
||||
func (op *AgentOsOperator) checkMySQL(funcArgs []string) (bool, []string) {
|
||||
|
||||
// 设置超时时间为 120 秒
|
||||
timeout := time.After(120 * time.Second)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
msg := "检查MySQL时间Pod的运行状态超时! 120s"
|
||||
log.Error(msg)
|
||||
return false, []string{msg}
|
||||
default:
|
||||
msg := "MySQL Pod已经启动!"
|
||||
if CheckPodStatus("helm-mysql-0", funcArgs[0]) {
|
||||
log.Info(msg)
|
||||
return true, []string{msg}
|
||||
}
|
||||
if !CheckPodStatusTimeout("helm-mysql-0", funcArgs[0], 180) {
|
||||
return false, []string{
|
||||
"helm-mysql 启动失败!",
|
||||
}
|
||||
|
||||
// 每隔5s检查一次
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (op *AgentOsOperator) deployMiddlewares(funcArgs []string) (bool, []string) {
|
||||
|
||||
Reference in New Issue
Block a user