func createKubernetes()

in cmd/hub/cmd/cluster.go [112:200]


func createKubernetes(args []string) error {
	// create <name or FQDN> <instance type> <count> [max count]
	if len(args) < 4 || len(args) > 5 {
		return errors.New("Create cluster command has several arguments - type of Kubernetes cluster, desired cluster name/domain, instance type, and node count")
	}

	kind := args[0]
	name := strings.ToLower(args[1])
	instanceType := args[2]
	count, err := strconv.ParseInt(args[3], 10, 32)
	if err != nil {
		return fmt.Errorf("Unable to parse count: %v", err)
	}
	maxCount := int64(0)
	if len(args) > 4 {
		maxCount, err = strconv.ParseInt(args[4], 10, 32)
		if err != nil {
			return fmt.Errorf("Unable to parse max count: %v", err)
		}
	}

	if !util.Contains(knownCreateKinds, kind) {
		return fmt.Errorf("Kubernetes cluster kind must be one of %v", knownCreateKinds)
	}

	nativeClusterName := ""
	switch kind {
	case "eks":
		if eksClusterName == "" {
			if strings.Contains(name, ".") {
				return errors.New("EKS cluster name (--eks-cluster) must be provided")
			}
			log.Printf("Setting --eks-cluster=%s", name)
			eksClusterName = name
		}
		nativeClusterName = eksClusterName
		if eksAdmin == "" {
			return errors.New("EKS cluster admin IAM user (--eks-admin) must be provided")
		}

	case "gke":
		if gkeClusterName == "" {
			if strings.Contains(name, ".") {
				return errors.New("GKE cluster name (--gke-cluster) must be provided")
			}
			log.Printf("Setting --gke-cluster=%s", name)
			gkeClusterName = name
		}
		nativeClusterName = gkeClusterName

	case "aks":
		if aksClusterName == "" {
			if strings.Contains(name, ".") {
				return errors.New("AKS cluster name (--aks-cluster) must be provided")
			}
			log.Printf("Setting --aks-cluster=%s", name)
			aksClusterName = name
		}
		nativeClusterName = aksClusterName
		if azureResourceGroup == "" {
			log.Printf("Azure resource group name (--azure-resource-group) not be provided - using default Cloud Account resource group")
		}
	}

	if !maybeValidHostname.MatchString(name) {
		return fmt.Errorf("`%s` doesn't look like a valid hostname", name)
	}

	if environmentSelector == "" {
		return errors.New("Environment name or id must be specified by --environment / -e")
	}

	if dryRun {
		waitAndTailDeployLogs = false
	}

	config.AggWarnings = false // confusing UIX otherwise

	api.CreateKubernetes(kind, name, environmentSelector, templateSelector,
		autoCreateTemplate, createNewTemplate, waitAndTailDeployLogs, dryRun,
		clusterRegion, clusterZone, nativeClusterName,
		eksAdmin, azureResourceGroup,
		api.ClusterOptions{InstanceType: instanceType, Count: int(count), MaxCount: int(maxCount),
			SpotPrice: spotPrice, PreemptibleVMs: preemptibleVMs, VolumeSize: volumeSize,
			Acm: acm, CertManager: certManager, Autoscaler: autoscaler,
			KubeDashboard: kubeDashboard, KubeDashboardMode: kubeDashboardMode})

	return nil
}