예제 #1
0
// Run executes worked node provisioning and tries to join an existing cluster.
func (j *Join) Run(out io.Writer) error {
	clusterInfo, err := kubenode.RetrieveTrustedClusterInfo(j.cfg)
	if err != nil {
		return err
	}

	connectionDetails, err := kubenode.EstablishMasterConnection(j.cfg, clusterInfo)
	if err != nil {
		return err
	}

	err = kubenode.CheckForNodeNameDuplicates(connectionDetails)
	if err != nil {
		return err
	}

	kubeconfig, err := kubenode.PerformTLSBootstrap(connectionDetails)
	if err != nil {
		return err
	}

	err = kubeadmutil.WriteKubeconfigIfNotExists("kubelet", kubeconfig)
	if err != nil {
		return err
	}

	fmt.Fprintf(out, joinDoneMsgf)
	return nil
}
예제 #2
0
// Run executes worker node provisioning and tries to join an existing cluster.
func (j *Join) Run(out io.Writer) error {
	cfg, err := discovery.For(j.cfg.Discovery)
	if err != nil {
		return err
	}
	if err := kubenode.PerformTLSBootstrap(cfg); err != nil {
		return err
	}
	if err := kubeconfigphase.WriteKubeconfigToDisk(path.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeconfigphase.KubeletKubeConfigFileName), cfg); err != nil {
		return err
	}

	fmt.Fprintf(out, joinDoneMsgf)
	return nil
}
예제 #3
0
// RunJoin executes worked node provisioning and tries to join an existing cluster.
func RunJoin(out io.Writer, cmd *cobra.Command, args []string, s *kubeadmapi.NodeConfiguration, skipPreFlight bool) error {
	// TODO(phase1+) this we are missing args from the help text, there should be a way to tell cobra about it
	if !skipPreFlight {
		fmt.Println("Running pre-flight checks")
		err := preflight.RunJoinNodeChecks()
		if err != nil {
			return err
		}
	} else {
		fmt.Println("Skipping pre-flight checks")
	}

	if len(args) == 0 {
		return fmt.Errorf("<cmd/join> must specify master IP address (see --help)")
	}
	s.MasterAddresses = append(s.MasterAddresses, args...)

	ok, err := kubeadmutil.UseGivenTokenIfValid(&s.Secrets)
	if !ok {
		if err != nil {
			return fmt.Errorf("<cmd/join> %v (see --help)\n", err)
		}
		return fmt.Errorf("Must specify --token (see --help)\n")
	}

	clusterInfo, err := kubenode.RetrieveTrustedClusterInfo(s)
	if err != nil {
		return err
	}

	connectionDetails, err := kubenode.EstablishMasterConnection(s, clusterInfo)
	if err != nil {
		return err
	}

	kubeconfig, err := kubenode.PerformTLSBootstrap(connectionDetails)
	if err != nil {
		return err
	}

	err = kubeadmutil.WriteKubeconfigIfNotExists("kubelet", kubeconfig)
	if err != nil {
		return err
	}

	fmt.Fprintf(out, joinDoneMsgf)
	return nil
}
예제 #4
0
// Run executes worked node provisioning and tries to join an existing cluster.
func (j *Join) Run(out io.Writer) error {
	clusterInfo, err := kubenode.RetrieveTrustedClusterInfo(j.cfg.Discovery.Token)
	if err != nil {
		return err
	}

	var cfg *clientcmdapi.Config
	// TODO: delete this first block when we move Token to the discovery interface
	if j.cfg.Discovery.Token != nil {
		connectionDetails, err := kubenode.EstablishMasterConnection(j.cfg.Discovery.Token, clusterInfo)
		if err != nil {
			return err
		}
		err = kubenode.CheckForNodeNameDuplicates(connectionDetails)
		if err != nil {
			return err
		}
		cfg, err = kubenode.PerformTLSBootstrapDeprecated(connectionDetails)
		if err != nil {
			return err
		}
	} else {
		cfg, err = discovery.For(j.cfg.Discovery)
		if err != nil {
			return err
		}
		if err := kubenode.PerformTLSBootstrap(cfg); err != nil {
			return err
		}
	}

	err = kubeadmutil.WriteKubeconfigIfNotExists("kubelet", cfg)
	if err != nil {
		return err
	}

	fmt.Fprintf(out, joinDoneMsgf)
	return nil
}