diff --git a/cmd/eksctl-anywhere/cmd/createcluster.go b/cmd/eksctl-anywhere/cmd/createcluster.go index ea002abc85b2..732bbd5d3081 100644 --- a/cmd/eksctl-anywhere/cmd/createcluster.go +++ b/cmd/eksctl-anywhere/cmd/createcluster.go @@ -21,8 +21,9 @@ import ( "github.com/aws/eks-anywhere/pkg/types" "github.com/aws/eks-anywhere/pkg/validations" "github.com/aws/eks-anywhere/pkg/validations/createvalidations" - "github.com/aws/eks-anywhere/pkg/workflow/management" + newManagement "github.com/aws/eks-anywhere/pkg/workflow/management" "github.com/aws/eks-anywhere/pkg/workflows" + "github.com/aws/eks-anywhere/pkg/workflows/management" "github.com/aws/eks-anywhere/pkg/workflows/workload" ) @@ -243,7 +244,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er return err } - wflw := &management.CreateCluster{ + wflw := &newManagement.CreateCluster{ Spec: clusterSpec, Bootstrapper: deps.Bootstrapper, CreateBootstrapClusterOptions: deps.Provider, @@ -255,7 +256,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er // Not all provider implementations want to bind hooks so we explicitly check if they // want to bind hooks before registering it. - if registrar, ok := deps.Provider.(management.CreateClusterHookRegistrar); ok { + if registrar, ok := deps.Provider.(newManagement.CreateClusterHookRegistrar); ok { wflw.WithHookRegistrar(registrar) } @@ -272,6 +273,23 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er ) err = createWorkloadCluster.Run(ctx, clusterSpec, createValidations) + } else if clusterSpec.Cluster.IsSelfManaged() && features.UseControllerViaCLIWorkflow().IsActive() { + logger.Info("Using the new workflow using the controller for management cluster create") + + createMgmtCluster := management.NewCreate( + deps.ClusterManager.ClientFactory, + deps.Bootstrapper, + deps.Provider, + deps.ClusterManager, + deps.GitOpsFlux, + deps.Writer, + deps.EksdInstaller, + deps.PackageInstaller, + deps.ClusterCreator, + deps.EksaInstaller, + ) + + err = createMgmtCluster.Run(ctx, clusterSpec, createValidations) } else { err = createCluster.Run(ctx, clusterSpec, createValidations, cc.forceClean) }