[Agent][Deploy] - cmii update

This commit is contained in:
zeaslity
2024-06-14 10:37:40 +08:00
parent 540d69ede2
commit d86bc43b28
799 changed files with 48148 additions and 203 deletions

22
agent-operator/K8sOperator.go Normal file → Executable file
View File

@@ -60,8 +60,8 @@ func init() {
CmiiDevClusterK8sConfig = "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\agent-operator\\config\\cmii-dev-cluster.yaml"
CmiiCoreClusterK8sConfig = "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\agent-operator\\config\\cmii-core-cluster.yaml"
case "linux":
CmiiDevClusterK8sConfig = ""
CmiiCoreClusterK8sConfig = ""
CmiiDevClusterK8sConfig = "/home/wdd/IdeaProjects/ProjectOctopus/agent-operator/config/cmii-dev-cluster.yaml"
CmiiCoreClusterK8sConfig = "/home/wdd/IdeaProjects/ProjectOctopus/agent-operator/config/cmii-core-cluster.yaml"
}
}
@@ -94,7 +94,7 @@ func DeleteByKubectl(applyFilePath string, cmiiEnv string) bool {
kubeconfig := GetK8sConfigByEnv(cmiiEnv)
cmd := exec.Command("/usr/local/bin/kubectl", "delete", "-f", applyFilePath)
cmd := exec.Command("kubectl", "delete", "-f", applyFilePath)
cmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubeconfig))
output, err := cmd.CombinedOutput()
if err != nil {
@@ -110,7 +110,7 @@ func ApplyByKubectl(applyFilePath string, cmiiEnv string) bool {
kubeconfig := GetK8sConfigByEnv(cmiiEnv)
cmd := exec.Command("/usr/local/bin/kubectl", "apply", "-f", applyFilePath)
cmd := exec.Command("kubectl", "apply", "-f", applyFilePath)
cmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubeconfig))
output, err := cmd.CombinedOutput()
if err != nil {
@@ -122,6 +122,20 @@ func ApplyByKubectl(applyFilePath string, cmiiEnv string) bool {
return true
}
func GetNodeWideByKubectl(cmiiEnv string) {
kubeconfig := GetK8sConfigByEnv(cmiiEnv)
cmd := exec.Command("kubectl", "get", "nodes", "-o", "wide")
cmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubeconfig))
output, err := cmd.CombinedOutput()
if err != nil {
log.ErrorF("failed to get nodes: %v\n%s", err, output)
return
}
fmt.Println(string(output))
}
func (op *CmiiK8sOperator) checkAndBuildCmiiK8sOperator() {
if op.DevClient == nil {