Fix loading kubeconfig file

* Don't set a default --kubeconfig flag value so NewDefaultClientConfigLoadingRules
will pick up the default locations

* Set an ExplicitPath using --kubeconfig flag value
This commit is contained in:
Ferran Rodenas 2016-12-20 22:26:16 +01:00
parent 87d7c6d083
commit ac716b14dc
1 changed files with 2 additions and 1 deletions

View File

@ -51,7 +51,7 @@ var (
apiserver = flags.String("apiserver", "", `The URL of the apiserver to use as a master`) apiserver = flags.String("apiserver", "", `The URL of the apiserver to use as a master`)
kubeconfig = flags.String("kubeconfig", "./config", "absolute path to the kubeconfig file") kubeconfig = flags.String("kubeconfig", "", "absolute path to the kubeconfig file")
help = flags.BoolP("help", "h", false, "Print help text") help = flags.BoolP("help", "h", false, "Print help text")
@ -114,6 +114,7 @@ func createKubeClient() (kubeClient clientset.Interface, err error) {
} else { } else {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
// if you want to change the loading rules (which files in which order), you can do so here // if you want to change the loading rules (which files in which order), you can do so here
loadingRules.ExplicitPath = *kubeconfig
configOverrides := &clientcmd.ConfigOverrides{} configOverrides := &clientcmd.ConfigOverrides{}
// if you want to change override values or bind them to flags, there are methods to help you // if you want to change override values or bind them to flags, there are methods to help you
kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)