Skip to content

Commit

Permalink
Enable management cluster create behind feature flag (#7488)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitalipaygude authored Feb 5, 2024
1 parent 52ca0fc commit 44b2242
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cmd/eksctl-anywhere/cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
Expand All @@ -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)
}

Expand All @@ -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)
}
Expand Down

0 comments on commit 44b2242

Please sign in to comment.