func (i *Init) Run(out io.Writer) error {
	// Get directories to write files to; can be faked if we're dry-running
	realCertsDir := i.cfg.CertificatesDir
	certsDirToWriteTo, kubeConfigDir, manifestDir, err := getDirectoriesToUse(i.dryRun, i.cfg.CertificatesDir)
	if err != nil {
		return fmt.Errorf("error getting directories to use: %v", err)
	}
	// certsDirToWriteTo is gonna equal cfg.CertificatesDir in the normal case, but gonna be a temp directory if dryrunning
	i.cfg.CertificatesDir = certsDirToWriteTo

	adminKubeConfigPath := filepath.Join(kubeConfigDir, kubeadmconstants.AdminKubeConfigFileName)

	println(realCertsDir, certsDirToWriteTo, kubeConfigDir, manifestDir, adminKubeConfigPath)

	if res, _ := certsphase.UsingExternalCA(i.cfg); !res {

		// PHASE 1: Generate certificates
		if err := certsphase.CreatePKIAssets(i.cfg); err != nil {
			return err
		}

		// PHASE 2: Generate kubeconfig files for the admin and the kubelet
		if err := kubeconfigphase.CreateInitKubeConfigFiles(kubeConfigDir, i.cfg); err != nil {
			return err
		}

	} else {
		fmt.Println("[externalca] The file 'ca.key' was not found, yet all other certificates are present. Using external CA mode - certificates or kubeconfig will not be generated.")
	}

	// Temporarily set cfg.CertificatesDir to the "real value" when writing controlplane manifests
	// This is needed for writing the right kind of manifests
	i.cfg.CertificatesDir = realCertsDir

	// PHASE 3: Bootstrap the control plane
	if err := controlplanephase.CreateInitStaticPodManifestFiles(manifestDir, i.cfg); err != nil {
		return fmt.Errorf("error creating init static pod manifest files: %v", err)
	}
	// Add etcd static pod spec only if external etcd is not configured
	if len(i.cfg.Etcd.Endpoints) == 0 {
		if err := etcdphase.CreateLocalEtcdStaticPodManifestFile(manifestDir, i.cfg); err != nil {
			return fmt.Errorf("error creating local etcd static pod manifest file: %v", err)
		}
	}

	return nil
}
// Run executes master node provisioning, including certificates, needed static pod manifests, etc.
Run executes master node provisioning, including certificates, needed static pod manifests, etc.
// Run executes master node provisioning including certificates needed static pod manifests etc .
func (i *Init) Run(out io.Writer) error {
	realCertsDir := i.cfg.CertificatesDir
	certsDirToWriteTo, kubeConfigDir, manifestDir, err := getDirectoriesToUse(i.dryRun, i.cfg.CertificatesDir)
	if err != nil {
		return fmt.Errorf("error getting directories to use: %v", err)
	}
	i.cfg.CertificatesDir = certsDirToWriteTo
	adminKubeConfigPath := filepath.Join(kubeConfigDir, kubeadmconstants.AdminKubeConfigFileName)
	println(realCertsDir, certsDirToWriteTo, kubeConfigDir, manifestDir, adminKubeConfigPath)
	if res, _ := certsphase.UsingExternalCA(i.cfg); !res {
		if err := certsphase.CreatePKIAssets(i.cfg); err != nil {
			return err
		}
		if err := kubeconfigphase.CreateInitKubeConfigFiles(kubeConfigDir, i.cfg); err != nil {
			return err
		}
	} else {
		fmt.Println("[externalca] The file 'ca.key' was not found, yet all other certificates are present. Using external CA mode - certificates or kubeconfig will not be generated.")
	}
	i.cfg.CertificatesDir = realCertsDir
	if err := controlplanephase.CreateInitStaticPodManifestFiles(manifestDir, i.cfg); err != nil {
		return fmt.Errorf("error creating init static pod manifest files: %v", err)
	}
	if len(i.cfg.Etcd.Endpoints) == 0 {
		if err := etcdphase.CreateLocalEtcdStaticPodManifestFile(manifestDir, i.cfg); err != nil {
			return fmt.Errorf("error creating local etcd static pod manifest file: %v", err)
		}
	}
	return nil
}
func ( i * Init ) Run ( out io . Writer ) error { realCertsDir := i . cfg . CertificatesDir certsDirToWriteTo , kubeConfigDir , manifestDir , err := getDirectoriesToUse ( i . dryRun , i . cfg . CertificatesDir ) if err != nil { return fmt . Errorf ( " " , err ) } i . cfg . CertificatesDir = certsDirToWriteTo adminKubeConfigPath := filepath . Join ( kubeConfigDir , kubeadmconstants . AdminKubeConfigFileName ) println ( realCertsDir , certsDirToWriteTo , kubeConfigDir , manifestDir , adminKubeConfigPath ) if res , _ := certsphase . UsingExternalCA ( i . cfg ) ; ! res { if err := certsphase . CreatePKIAssets ( i . cfg ) ; err != nil { return err } if err := kubeconfigphase . CreateInitKubeConfigFiles ( kubeConfigDir , i . cfg ) ; err != nil { return err } } else { fmt . Println ( " " ) } i . cfg . CertificatesDir = realCertsDir if err := controlplanephase . CreateInitStaticPodManifestFiles ( manifestDir , i . cfg ) ; err != nil { return fmt . Errorf ( " " , err ) } if len ( i . cfg . Etcd . Endpoints ) == 0 { if err := etcdphase . CreateLocalEtcdStaticPodManifestFile ( manifestDir , i . cfg ) ; err != nil { return fmt . Errorf ( " " , err ) } } return nil }
Run executes master node provisioning, including certificates, needed static pod manifests, etc.
Run executes master node provisioning including certificates needed static pod manifests etc .
// Get directories to write files to; can be faked if we're dry-running // certsDirToWriteTo is gonna equal cfg.CertificatesDir in the normal case, but gonna be a temp directory if dryrunning // PHASE 1: Generate certificates // PHASE 2: Generate kubeconfig files for the admin and the kubelet // Temporarily set cfg.CertificatesDir to the "real value" when writing controlplane manifests // This is needed for writing the right kind of manifests // PHASE 3: Bootstrap the control plane // Add etcd static pod spec only if external etcd is not configured