Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding kubectl test for minikube #398

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"

Expand Down Expand Up @@ -49,7 +50,7 @@ var startCmd = &cobra.Command{
Use: "start",
Short: "Starts a local kubernetes cluster.",
Long: `Starts a local kubernetes cluster using Virtualbox. This command
assumes you already have Virtualbox installed.`,
assumes you already have Virtualbox & kubectl installed.`,
Run: runStart,
}

Expand Down Expand Up @@ -102,6 +103,15 @@ func runStart(cmd *cobra.Command, args []string) {
kubeHost = strings.Replace(kubeHost, ":2376", ":"+strconv.Itoa(constants.APIServerPort), -1)
fmt.Printf("Kubernetes is available at %s.\n", kubeHost)

//Checking for kubectl
fmt.Printf("Checking for Kubectl ...\n")
path, err := exec.LookPath("kubectl")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be:

if _, err := exec.LookPath("kubectl") {
  glog.Errorln(...)
}

if err != nil {
log.Fatal("Kubectl is not installed.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you switch this to something like:

glog.Errorln("Kubectl is not installed.")
os.Exit(1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually lets just leave this as a warning, kubectl isn't the only way to interact with kubernetes so we shouldn't error if the user doesn't have it installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we can add a better help message to direct where to download it from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jimmidyson for the suggestion.I will add some nice suggestion for kubectl.

}
fmt.Printf("Kubectl is configured and installed.")


// setup kubeconfig
name := constants.MinikubeContext
certAuth := constants.MakeMiniPath("ca.crt")
Expand Down