[agent-operator] - cmii deploy part - basic accomplished
This commit is contained in:
@@ -50,8 +50,8 @@ const (
|
||||
workerThread = 4
|
||||
)
|
||||
|
||||
var CmiiDevClusterK8sConfig string
|
||||
var CmiiCoreClusterK8sConfig string
|
||||
var CmiiDevClusterK8sConfig string // used for kubectl
|
||||
var CmiiCoreClusterK8sConfig string // used for kubectl
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -953,6 +953,35 @@ func (op *CmiiK8sOperator) PodExec(cmiiEnv string, podInterface CmiiPodInterface
|
||||
return stdout, stderr
|
||||
}
|
||||
|
||||
func (op *CmiiK8sOperator) PodStatusCheckTimeout(specificPod string, cmiiEnv string, waitTimeOut int) bool {
|
||||
|
||||
op.changeOperatorEnv(cmiiEnv)
|
||||
client := op.CurrentClient
|
||||
|
||||
// 设置超时时间和时间间隔
|
||||
timeout := time.After(time.Duration(waitTimeOut) * time.Second)
|
||||
tick := time.Tick(5 * time.Second)
|
||||
|
||||
// 监控Pod状态
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
log.ErrorF("[K8sCheckPodStatusTimeout] - 命名空间: [%s], Pod名称: [%s], 状态: 失败!", cmiiEnv, specificPod)
|
||||
return false
|
||||
case <-tick:
|
||||
pod, err := client.CoreV1().Pods(cmiiEnv).Get(context.TODO(), specificPod, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
log.ErrorF("[K8sCheckPodStatusTimeout] - 命名空间: [%s], Pod名称: [%s], 获取Pod信息失败 !", cmiiEnv, err.Error())
|
||||
} else {
|
||||
log.DebugF("[K8sCheckPodStatusTimeout] - 命名空间: [%s], Pod名称: [%s], 状态: [%s]", cmiiEnv, pod.Name, pod.Status.Phase)
|
||||
if pod.Status.Phase == corev1.PodRunning || pod.Status.Phase == corev1.PodSucceeded {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (op *CmiiK8sOperator) NodeAll(cmiiEnv string) (nodeListR []corev1.Node) {
|
||||
op.changeOperatorEnv(cmiiEnv)
|
||||
client := op.CurrentClient
|
||||
|
||||
Reference in New Issue
Block a user