diff --git a/cli/cmd/plugin/standalone-cluster/cluster/cluster.go b/cli/cmd/plugin/standalone-cluster/cluster/cluster.go index c3c7cdfb53..d48eae9015 100644 --- a/cli/cmd/plugin/standalone-cluster/cluster/cluster.go +++ b/cli/cmd/plugin/standalone-cluster/cluster/cluster.go @@ -22,24 +22,13 @@ type KubernetesCluster struct { Kubeconfig string } -// CreateOpts contains data to be used when creating a new cluster. -type CreateOpts struct { - // Name is the name for the new cluster. - Name string - // KubeconfigPath is the path to the kubeconfig to use. - KubeconfigPath string - // Config contains the full cluster creation details passed in from the user when calling - // create. - Config *config.LocalClusterConfig -} - // ClusterManager provides methods for creating and managing Kubernetes // clusters. //nolint:golint type ClusterManager interface { // Create will create a new cluster or return an error indicating a problem // during creation. - Create(opts *CreateOpts) (*KubernetesCluster, error) + Create(c *config.LocalClusterConfig) (*KubernetesCluster, error) // Get retrieves cluster information or return an error indicating a problem. Get(clusterName string) (*KubernetesCluster, error) // List gets a list of all local clusters. diff --git a/cli/cmd/plugin/standalone-cluster/cluster/kind.go b/cli/cmd/plugin/standalone-cluster/cluster/kind.go index f6d4cf083d..28ad8ff225 100644 --- a/cli/cmd/plugin/standalone-cluster/cluster/kind.go +++ b/cli/cmd/plugin/standalone-cluster/cluster/kind.go @@ -37,25 +37,26 @@ type KindClusterManager struct { } // Create will create a new kind cluster or return an error. -func (kcm KindClusterManager) Create(opts *CreateOpts) (*KubernetesCluster, error) { +func (kcm KindClusterManager) Create(c *config.LocalClusterConfig) (*KubernetesCluster, error) { kindProvider := kindCluster.NewProvider() - clusterConfig := kindCluster.CreateWithKubeconfigPath(opts.KubeconfigPath) + clusterConfig := kindCluster.CreateWithKubeconfigPath(c.KubeconfigPath) + nodeConfig := kindCluster.CreateWithNodeImage(c.NodeImage) // TODO(stmcginnis): Determine what we need to do for kind configuration parsedKindConfig := []byte(defaultKindConfig) kindConfig := kindCluster.CreateWithRawConfig(parsedKindConfig) - err := kindProvider.Create(opts.Name, clusterConfig, kindConfig) + err := kindProvider.Create(c.ClusterName, clusterConfig, kindConfig, nodeConfig) if err != nil { return nil, err } kc := &KubernetesCluster{ - Name: opts.Name, - Kubeconfig: opts.KubeconfigPath, + Name: c.ClusterName, + Kubeconfig: c.KubeconfigPath, } - if strings.Contains(opts.Config.Cni, "antrea") { - nodes, _ := kindProvider.ListNodes(opts.Name) + if strings.Contains(c.Cni, "antrea") { + nodes, _ := kindProvider.ListNodes(c.ClusterName) for _, n := range nodes { if err := patchForAntrea(n.String()); err != nil { //nolint:staticcheck // TODO(stmcginnis): We probably don't want to just error out diff --git a/cli/cmd/plugin/standalone-cluster/config/config.go b/cli/cmd/plugin/standalone-cluster/config/config.go index 50efa96093..c6b53c067c 100644 --- a/cli/cmd/plugin/standalone-cluster/config/config.go +++ b/cli/cmd/plugin/standalone-cluster/config/config.go @@ -51,6 +51,12 @@ type PortMap struct { type LocalClusterConfig struct { // ClusterName is the name of the cluster. ClusterName string `yaml:"ClusterName"` + // KubeconfigPath is the path to the kubeconfig to use. + KubeconfigPath string `yaml:"KubeconfigPath"` + // NodeImage is the host OS image to use for Kubernetes nodes. + // It is typically resolved, automatically, in the Taznu Kubernetes Release (TKR) BOM, + // but also can be overridden in configuration. + NodeImage string `yaml:"NodeImage"` // Provider is the local infrastructure provider to use (e.g. kind). Provider string `yaml:"Provider"` // ProviderConfiguration offers optional provider-specific configuration. diff --git a/cli/cmd/plugin/standalone-cluster/tanzu/tanzu.go b/cli/cmd/plugin/standalone-cluster/tanzu/tanzu.go index 2f3f6cd8cc..8f82513f3f 100644 --- a/cli/cmd/plugin/standalone-cluster/tanzu/tanzu.go +++ b/cli/cmd/plugin/standalone-cluster/tanzu/tanzu.go @@ -153,6 +153,8 @@ func (t *TanzuLocal) Deploy(lcConfig *config.LocalClusterConfig) error { // base image log.Event("\\U+1F5BC", " Selected base image\n") log.Style(outputIndent, logger.ColorLightGrey).Infof("%s\n", t.bom.GetTKRNodeImage()) + lcConfig.NodeImage = t.bom.GetTKRNodeImage() + // core package repository log.Event("\\U+1F4E6", "Selected core package repository\n") log.Style(outputIndent, logger.ColorLightGrey).Infof("%s\n", t.bom.GetTKRCoreRepoBundlePath()) @@ -506,12 +508,8 @@ func runClusterCreate(lcConfig *config.LocalClusterConfig) (*cluster.KubernetesC } kcPath := filepath.Join(clusterDir, "kube.conf") clusterManager := cluster.NewKindClusterManager() - clusterCreateOpts := cluster.CreateOpts{ - Name: lcConfig.ClusterName, - KubeconfigPath: kcPath, - Config: lcConfig, - } - kc, err := clusterManager.Create(&clusterCreateOpts) + lcConfig.KubeconfigPath = kcPath + kc, err := clusterManager.Create(lcConfig) if err != nil { return nil, err }