From 7bcd009239c51466edfd1796e6435a84b43f0bae Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期五, 02 六月 2023 16:25:54 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/aps_deploy --- src/util/util.go | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/util/util.go b/src/util/util.go index 3da9a85..f396fcd 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -12,14 +12,14 @@ ) // homeDir 鑾峰彇褰撳墠鐢ㄦ埛鐨勫鐩綍璺緞 -func homeDir() string { +func HomeDir() string { if h := os.Getenv("HOME"); h != "" { return h } return os.Getenv("USERPROFILE") // Windows 鐜涓嬭幏鍙栫敤鎴风洰褰� } -func sshExec(nodeIP, sshUsername, sshPassword, remoteSSHCommand string, sshPort int) (string, error) { +func SSHExec(nodeIP, sshUsername, sshPassword, remoteSSHCommand string, sshPort int) (string, error) { // SSH 杩炴帴閰嶇疆 config := &ssh.ClientConfig{ User: sshUsername, @@ -97,20 +97,20 @@ } // 瀹夎Docker -func installDocker(nodeIP, sshUsername, sshPassword string, sshPort int) error { +func InstallDocker(nodeIP, sshUsername, sshPassword string, sshPort int) error { // 妫�鏌ocker鏄惁宸插畨瑁� checkCommand := "which docker" - _, err := sshExec(nodeIP, sshUsername, sshPassword, checkCommand, sshPort) + _, err := SSHExec(nodeIP, sshUsername, sshPassword, checkCommand, sshPort) if err == nil { fmt.Println("Docker is already installed on the remote server.") return nil } // 瀹夎Docker - installCommand := "sudo curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh" - _, err = sshExec(nodeIP, sshUsername, sshPassword, installCommand, sshPort) + installCommand := "sudo curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh && sudo systemctl start docker && sudo systemctl enable docker" + _, err = SSHExec(nodeIP, sshUsername, sshPassword, installCommand, sshPort) if err != nil { - return fmt.Errorf("failed to install Docker on the remote server: %v", err) + return fmt.Errorf("failed to install Docker on the remote server:%v %v", nodeIP, err) } fmt.Println("Docker has been installed on the remote server.") @@ -118,7 +118,7 @@ } // Create an HTTP client with insecure TLS configuration -func createHTTPClient() *http.Client { +func CreateHTTPClient() *http.Client { transport := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } @@ -126,10 +126,10 @@ } // 瀹夎kubectl -func installKubectl(nodeIP, sshUsername, sshPassword string, sshPort int) error { +func InstallKubectl(nodeIP, sshUsername, sshPassword string, sshPort int) error { // 妫�鏌ubectl鏄惁宸插畨瑁� checkCommand := "which kubectl" - _, err := sshExec(nodeIP, sshUsername, sshPassword, checkCommand, sshPort) + _, err := SSHExec(nodeIP, sshUsername, sshPassword, checkCommand, sshPort) if err == nil { fmt.Println("kubectl is already installed on the remote server.") return nil @@ -137,7 +137,7 @@ // 瀹夎kubectl installCommand := "sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x kubectl && sudo mv kubectl /usr/local/bin/" - _, err = sshExec(nodeIP, sshUsername, sshPassword, installCommand, sshPort) + _, err = SSHExec(nodeIP, sshUsername, sshPassword, installCommand, sshPort) if err != nil { return fmt.Errorf("failed to install kubectl on the remote server: %v", err) } -- Gitblit v1.8.0