github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/integration-tests/add_node.go (about) 1 package integration_tests 2 3 import ( 4 "fmt" 5 "os" 6 "os/exec" 7 "strings" 8 9 . "github.com/onsi/ginkgo" 10 ) 11 12 func addNodeToCluster(newNode NodeDeets, sshKey string, labels []string, roles []string) error { 13 By("Adding new worker") 14 cmd := exec.Command("./kismatic", "install", "add-node", "-f", "kismatic-testing.yaml", "--roles", strings.Join(roles, ","), newNode.Hostname, newNode.PublicIP, newNode.PrivateIP) 15 if len(labels) > 0 { 16 cmd.Args = append(cmd.Args, "--labels", strings.Join(labels, ",")) 17 } 18 cmd.Stdout = os.Stdout 19 cmd.Stderr = os.Stderr 20 if err := cmd.Run(); err != nil { 21 return fmt.Errorf("error running add node command: %v", err) 22 } 23 24 By("Verifying that the node was added") 25 sshCmd := fmt.Sprintf("sudo kubectl --kubeconfig /root/.kube/config get nodes %s", strings.ToLower(newNode.Hostname)) // the api server is case-sensitive. 26 out, err := executeCmd(sshCmd, newNode.PublicIP, newNode.SSHUser, sshKey) 27 if err != nil { 28 return fmt.Errorf("error getting nodes using kubectl: %v. Command output was: %s", err, out) 29 } 30 31 By("Verifying that the node is in the ready state") 32 if !strings.Contains(strings.ToLower(out), "ready") { 33 return fmt.Errorf("the node was not in ready state. node details: %s", out) 34 } 35 return nil 36 }