func CreateCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Logger, ksEnabled, verbose, skipCheck, skipPullImages, inCluster, deployLocalStorage bool, downloadCmd, containerManager string) error {
	currentDir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		return errors.Wrap(err, "Failed to get current dir")
	}
	if err := util.CreateDir(fmt.Sprintf("%s/kubekey", currentDir)); err != nil {
		return errors.Wrap(err, "Failed to create work dir")
	}
	cfg, objName, err := config.ParseClusterCfg(clusterCfgFile, k8sVersion, ksVersion, ksEnabled, logger)
	if err != nil {
		return errors.Wrap(err, "Failed to download cluster config")
	}
	for _, host := range cfg.Spec.Hosts {
		if host.Name != strings.ToLower(host.Name) {
			return errors.New("Please do not use uppercase letters in hostname: " + host.Name)
		}
	}
	var clientset *kubekeyclientset.Clientset
	if inCluster {
		c, err := kubekeycontroller.NewKubekeyClient()
		if err != nil {
			return err
		}
		clientset = c
	}
	executorInstance := &executor.Executor{
		ObjName:            objName,
		Cluster:            &cfg.Spec,
		Logger:             logger,
		SourcesDir:         "",
		Debug:              verbose,
		SkipCheck:          skipCheck,
		SkipPullImages:     skipPullImages,
		DeployLocalStorage: deployLocalStorage,
		InCluster:          inCluster,
		ClientSet:          clientset,
		ContainerManager:   containerManager,
		Connector:          ssh.NewDialer(),
	}
	executorInstance.DeployLocalStorage = deployLocalStorage
	executorInstance.DownloadCommand = func(path, url string) string {
		return fmt.Sprintf(downloadCmd, path, url)
	}
	return Execute(executorInstance)
}
CreateCluster is used to create cluster based on the given parameters or configuration file.
package install
import (
	"encoding/base64"
	"fmt"
	"github.com/kubesphere/kubekey/pkg/connector/ssh"
	"github.com/kubesphere/kubekey/pkg/container-engine"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	kubekeyclientset "github.com/kubesphere/kubekey/clients/clientset/versioned"
	kubekeycontroller "github.com/kubesphere/kubekey/controllers/kubekey"
	"github.com/kubesphere/kubekey/pkg/addons"
	"github.com/kubesphere/kubekey/pkg/config"
	"github.com/kubesphere/kubekey/pkg/etcd"
	"github.com/kubesphere/kubekey/pkg/kubesphere"
	"github.com/kubesphere/kubekey/pkg/plugins/network"
	"github.com/kubesphere/kubekey/pkg/util"
	"github.com/kubesphere/kubekey/pkg/util/executor"
	"github.com/kubesphere/kubekey/pkg/util/manager"
	"github.com/pkg/errors"
	log "github.com/sirupsen/logrus"
)