| | |
| | | func InstallDocker(nodeIP, sshUsername, sshPassword string, sshPort int) error { |
| | | // 检查Docker是否已安装 |
| | | 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) |
| | | _, err = SSHExec(nodeIP, sshUsername, sshPassword, installCommand, sshPort) |
| | | if err != nil { |
| | | return fmt.Errorf("failed to install Docker on the remote server: %v", err) |
| | | } |
| | |
| | | func InstallKubectl(nodeIP, sshUsername, sshPassword string, sshPort int) error { |
| | | // 检查kubectl是否已安装 |
| | | 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 |
| | |
| | | |
| | | // 安装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) |
| | | } |