[ Agent ] [ APP ] - accomplish rke and dashboard

This commit is contained in:
zeaslity
2023-11-20 16:13:42 +08:00
parent 72269894db
commit c47e6b5ed1
7 changed files with 416 additions and 22 deletions

View File

@@ -1103,6 +1103,107 @@ func (op *AgentOsOperator) installHarborExec() (bool, []string) {
return true, []string{msg}
}
func (op *AgentOsOperator) restartHarborExec() (bool, []string) {
// check pods all run
allHarborContainerName := []string{
"harbor-log",
"harbor-db",
"harbor-portal",
"redis",
"registryctl",
"registry",
"registry",
"harbor-core",
"nginx",
"harbor-jobservice",
}
harborServiceRunningHealthy := true
for _, container := range allHarborContainerName {
ok, _ := PipelineCommandExecutor([][]string{
{
"docker",
"ps",
},
{
"grep",
"-c",
container,
},
})
if !ok {
harborServiceRunningHealthy = false
msg := fmt.Sprintf("[restartHarborExec] - harbor service unhealthy, container [ %s ] not running, prepare to restart !", container)
log.Warn(msg)
break
}
}
if harborServiceRunningHealthy {
return true, []string{
"[restartHarborExec] - harbor container run healthy !",
}
}
// docker-compose.yml exists
harborDockerComposeFile := "/root/wdd/harbor/docker-compose.yml"
if !BasicFileExistAndNotNull(harborDockerComposeFile) {
errorLog := fmt.Sprintf("[restartHarborExec] - harborDockerComposeFile %s not exist !", harborDockerComposeFile)
log.Error(errorLog)
return false, []string{
errorLog,
}
}
// execute docker-compose up
if !BasicCommandExists("docker-compose") {
return false, []string{
"[restartHarborExec] - docker-compose not exist !",
}
}
log.InfoF("[restartHarborExec] - prepare to restart harbor docker compose !")
ok, resultLog := AllCommandExecutor([]string{
"docker-compose",
"-f",
harborDockerComposeFile,
"up",
"-d",
})
if !ok {
return false, resultLog
}
// wait
// check pods all run
for _, container := range allHarborContainerName {
ok, _ := PipelineCommandExecutor([][]string{
{
"docker",
"ps",
},
{
"grep",
"-c",
container,
},
})
if !ok {
errLog := fmt.Sprintf("[restartHarborExec] - harbor service [ %s ] restart failed !", container)
log.Error(errLog)
return false, []string{
errLog,
}
}
}
return true, []string{
"[restartHarborExec] - harbor container restarted and run healthy !",
}
}
func (op *AgentOsOperator) chronyToPublicNTP() [][]string {
serverIPInV4 := op.AgentServerInfo.ServerIPInV4