[ Agent ] [ Executor ] 初步完成部署的函数功能
This commit is contained in:
27
agent-go/executor/K8sFunction.go
Normal file
27
agent-go/executor/K8sFunction.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user