Beispiel #1
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
}
Beispiel #2
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
}