[ Agent ] [ Executor ] 初步完成部署的函数功能

This commit is contained in:
zeaslity
2023-08-08 14:25:01 +08:00
parent 8e2eacfa47
commit e5af31bb38
8 changed files with 872 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
package executor
import "strings"
var configFilePath = "/root/.kube/config"
func CheckPodStatus(specific string, supreme string) bool {
if !BaseCommandExists("kubectl") {
log.Error("kubectl命令不存在无法查看Pod状态请查看")
}
executor, err := SingleLineCommandExecutor([]string{
"kubectl", "-n", supreme, "get", "pod", specific, "-o", "jsonpath='{.status.phase}'",
})
if err != nil {
return false
}
for _, resultLine := range executor {
if strings.HasPrefix(resultLine, "Running") {
return true
}
}
return false
}