diff --git a/cmd/kubeadm/app/cmd/join.go b/cmd/kubeadm/app/cmd/join.go index 9fb8346062a8c..3371d70e185fc 100644 --- a/cmd/kubeadm/app/cmd/join.go +++ b/cmd/kubeadm/app/cmd/join.go @@ -33,6 +33,7 @@ import ( kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig" "k8s.io/kubernetes/cmd/kubeadm/app/preflight" kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" + "k8s.io/kubernetes/pkg/api" clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api" "k8s.io/kubernetes/pkg/runtime" @@ -129,7 +130,7 @@ func (j *Join) Validate() error { return validation.ValidateNodeConfiguration(j.cfg).ToAggregate() } -// Run executes worked node provisioning and tries to join an existing cluster. +// Run executes worker node provisioning and tries to join an existing cluster. func (j *Join) Run(out io.Writer) error { var cfg *clientcmdapi.Config // TODO: delete this first block when we move Token to the discovery interface @@ -138,7 +139,6 @@ func (j *Join) Run(out io.Writer) error { if err != nil { return err } - connectionDetails, err := kubenode.EstablishMasterConnection(j.cfg.Discovery.Token, clusterInfo) if err != nil { return err @@ -161,8 +161,7 @@ func (j *Join) Run(out io.Writer) error { } } - err := kubeconfigphase.WriteKubeconfigToDisk(path.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeconfigphase.KubeletKubeConfigFileName), cfg) - if err != nil { + if err := kubeconfigphase.WriteKubeconfigToDisk(path.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeconfigphase.KubeletKubeConfigFileName), cfg); err != nil { return err } diff --git a/cmd/kubeadm/app/discovery/discovery.go b/cmd/kubeadm/app/discovery/discovery.go index ef5e30870671a..332f54291b962 100644 --- a/cmd/kubeadm/app/discovery/discovery.go +++ b/cmd/kubeadm/app/discovery/discovery.go @@ -23,9 +23,19 @@ import ( clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api" ) -func For(c kubeadmapi.Discovery) (*clientcmdapi.Config, error) { +// For identifies and executes the desired discovery mechanism. +func For(d kubeadmapi.Discovery) (*clientcmdapi.Config, error) { switch { + case d.File != nil: + return runFileDiscovery(d.File) default: - return nil, fmt.Errorf("unimplemented") + return nil, fmt.Errorf("Couldn't find a valid discovery configuration. Please provide one.") + } +} + +// runFileDiscovery executes file-based discovery. +func runFileDiscovery(fd *kubeadmapi.FileDiscovery) (*clientcmdapi.Config, error) { + return clientcmd.LoadFromFile(fd.Path) +} } }