Ejemplo n.º 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
}
Ejemplo n.º 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
}