Skip to content

Commit

Permalink
kubeadm: added file discovery.
Browse files Browse the repository at this point in the history
  • Loading branch information
pires committed Jan 6, 2017
1 parent ed5414d commit 18370ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 3 additions & 4 deletions cmd/kubeadm/app/cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down
14 changes: 12 additions & 2 deletions cmd/kubeadm/app/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

0 comments on commit 18370ba

Please sign in to comment.