From 9f8f1150ddc2be5b72fa0836cffcf21dfe8df7ad Mon Sep 17 00:00:00 2001 From: EKS Distro PR Bot <75336432+eks-distro-pr-bot@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:26:31 -0500 Subject: [PATCH 1/4] [PR BOT] Generate release testdata files (#6702) From 500dfa1d2bb2c0fa3eaf1f72fc862bd044328cc5 Mon Sep 17 00:00:00 2001 From: Mitali Paygude Date: Wed, 29 Nov 2023 14:40:26 -0800 Subject: [PATCH 2/4] Mgmt cluster create unify POC --- cmd/eksctl-anywhere/cmd/createcluster.go | 2 + pkg/api/v1alpha1/cluster_webhook.go | 6 +- pkg/clustermanager/cluster_manager.go | 41 +- pkg/workflows/create.go | 950 +++++++++++------------ pkg/workflows/create_mgmt_poc.go | 555 +++++++++++++ 5 files changed, 1057 insertions(+), 497 deletions(-) create mode 100644 pkg/workflows/create_mgmt_poc.go diff --git a/cmd/eksctl-anywhere/cmd/createcluster.go b/cmd/eksctl-anywhere/cmd/createcluster.go index f67779f68dac..991040118fb4 100644 --- a/cmd/eksctl-anywhere/cmd/createcluster.go +++ b/cmd/eksctl-anywhere/cmd/createcluster.go @@ -180,6 +180,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er WithBootstrapper(). WithCliConfig(cliConfig). WithClusterManager(clusterSpec.Cluster, clusterManagerTimeoutOpts). + WithClusterApplier(). WithProvider(cc.fileName, clusterSpec.Cluster, cc.skipIpCheck, cc.hardwareCSVPath, cc.forceClean, cc.tinkerbellBootstrapIP, skippedValidations, cc.providerOptions). WithGitOpsFlux(clusterSpec.Cluster, clusterSpec.FluxConfig, cliConfig). WithWriter(). @@ -211,6 +212,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er deps.Writer, deps.EksdInstaller, deps.PackageInstaller, + deps.ClusterApplier, ) validationOpts := &validations.Opts{ diff --git a/pkg/api/v1alpha1/cluster_webhook.go b/pkg/api/v1alpha1/cluster_webhook.go index 5e7c6a87ad84..05b1d67a86ae 100644 --- a/pkg/api/v1alpha1/cluster_webhook.go +++ b/pkg/api/v1alpha1/cluster_webhook.go @@ -61,9 +61,9 @@ func (r *Cluster) ValidateCreate() error { var allErrs field.ErrorList - if !r.IsReconcilePaused() && r.IsSelfManaged() { - return apierrors.NewBadRequest("creating new cluster on existing cluster is not supported for self managed clusters") - } + // if !r.IsReconcilePaused() && r.IsSelfManaged() { + // return apierrors.NewBadRequest("creating new cluster on existing cluster is not supported for self managed clusters") + // } if r.Spec.EtcdEncryption != nil { allErrs = append(allErrs, field.Invalid(field.NewPath("spec.etcdEncryption"), r.Spec.EtcdEncryption, "etcdEncryption is not supported during cluster creation")) diff --git a/pkg/clustermanager/cluster_manager.go b/pkg/clustermanager/cluster_manager.go index 3da0545a6de0..1aff49fee8a8 100644 --- a/pkg/clustermanager/cluster_manager.go +++ b/pkg/clustermanager/cluster_manager.go @@ -26,7 +26,7 @@ import ( "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/clustermanager/internal" - "github.com/aws/eks-anywhere/pkg/clustermarshaller" + // "github.com/aws/eks-anywhere/pkg/clustermarshaller" "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/diagnostics" "github.com/aws/eks-anywhere/pkg/executables" @@ -411,13 +411,13 @@ func (c *ClusterManager) CreateWorkloadCluster(ctx context.Context, managementCl ExistingManagement: managementCluster.ExistingManagement, } - if err := c.applyProviderManifests(ctx, clusterSpec, managementCluster, provider); err != nil { - return nil, err - } + // if err := c.applyProviderManifests(ctx, clusterSpec, managementCluster, provider); err != nil { + // return nil, err + // } - if err := c.waitUntilControlPlaneAvailable(ctx, clusterSpec, managementCluster); err != nil { - return nil, err - } + // if err := c.waitUntilControlPlaneAvailable(ctx, clusterSpec, managementCluster); err != nil { + // return nil, err + // } logger.V(3).Info("Waiting for workload kubeconfig generation", "cluster", clusterName) @@ -459,6 +459,8 @@ func (c *ClusterManager) waitUntilControlPlaneAvailable( // If we have external etcd we need to wait for that first as control plane nodes can't // come up without it. if clusterSpec.Cluster.Spec.ExternalEtcdConfiguration != nil { + + // time.Sleep(10 * time.Minute) logger.V(3).Info("Waiting for external etcd to be ready", "cluster", clusterSpec.Cluster.Name) err := c.clusterClient.WaitForManagedExternalEtcdReady( ctx, @@ -512,6 +514,7 @@ func (c *ClusterManager) applyProviderManifests( } func (c *ClusterManager) getWorkloadClusterKubeconfig(ctx context.Context, clusterName string, managementCluster *types.Cluster, w io.Writer) error { + fmt.Printf("clustername %s", clusterName) kubeconfig, err := c.clusterClient.GetWorkloadKubeconfig(ctx, clusterName, managementCluster) if err != nil { return fmt.Errorf("getting workload kubeconfig: %v", err) @@ -1149,19 +1152,19 @@ func (c *ClusterManager) CreateEKSAResources(ctx context.Context, cluster *types } } - clusterSpec.Cluster.PauseReconcile() - datacenterConfig.PauseReconcile() + // clusterSpec.Cluster.PauseReconcile() + // datacenterConfig.PauseReconcile() - resourcesSpec, err := clustermarshaller.MarshalClusterSpec(clusterSpec, datacenterConfig, machineConfigs) - if err != nil { - return err - } - logger.V(4).Info("Applying eksa yaml resources to cluster") - logger.V(6).Info(string(resourcesSpec)) - if err = c.applyResource(ctx, cluster, resourcesSpec); err != nil { - return err - } - if err = c.ApplyBundles(ctx, clusterSpec, cluster); err != nil { + // resourcesSpec, err := clustermarshaller.MarshalClusterSpec(clusterSpec, datacenterConfig, machineConfigs) + // if err != nil { + // return err + // } + // logger.V(4).Info("Applying eksa yaml resources to cluster") + // logger.V(6).Info(string(resourcesSpec)) + // if err = c.applyResource(ctx, cluster, resourcesSpec); err != nil { + // return err + // } + if err := c.ApplyBundles(ctx, clusterSpec, cluster); err != nil { return err } return c.ApplyReleases(ctx, clusterSpec, cluster) diff --git a/pkg/workflows/create.go b/pkg/workflows/create.go index d4ef7f36735c..343284d1a9ad 100644 --- a/pkg/workflows/create.go +++ b/pkg/workflows/create.go @@ -1,477 +1,477 @@ package workflows -import ( - "context" - "fmt" - - "github.com/aws/eks-anywhere/pkg/cluster" - "github.com/aws/eks-anywhere/pkg/clustermarshaller" - "github.com/aws/eks-anywhere/pkg/constants" - "github.com/aws/eks-anywhere/pkg/filewriter" - "github.com/aws/eks-anywhere/pkg/logger" - "github.com/aws/eks-anywhere/pkg/providers" - "github.com/aws/eks-anywhere/pkg/task" - "github.com/aws/eks-anywhere/pkg/types" - "github.com/aws/eks-anywhere/pkg/validations" - "github.com/aws/eks-anywhere/pkg/workflows/interfaces" -) - -type Create struct { - bootstrapper interfaces.Bootstrapper - provider providers.Provider - clusterManager interfaces.ClusterManager - gitOpsManager interfaces.GitOpsManager - writer filewriter.FileWriter - eksdInstaller interfaces.EksdInstaller - packageInstaller interfaces.PackageInstaller -} - -func NewCreate(bootstrapper interfaces.Bootstrapper, provider providers.Provider, - clusterManager interfaces.ClusterManager, gitOpsManager interfaces.GitOpsManager, - writer filewriter.FileWriter, eksdInstaller interfaces.EksdInstaller, - packageInstaller interfaces.PackageInstaller, -) *Create { - return &Create{ - bootstrapper: bootstrapper, - provider: provider, - clusterManager: clusterManager, - gitOpsManager: gitOpsManager, - writer: writer, - eksdInstaller: eksdInstaller, - packageInstaller: packageInstaller, - } -} - -func (c *Create) Run(ctx context.Context, clusterSpec *cluster.Spec, validator interfaces.Validator, forceCleanup bool) error { - if forceCleanup { - if err := c.bootstrapper.DeleteBootstrapCluster(ctx, &types.Cluster{ - Name: clusterSpec.Cluster.Name, - }, constants.Create, forceCleanup); err != nil { - return err - } - } - commandContext := &task.CommandContext{ - Bootstrapper: c.bootstrapper, - Provider: c.provider, - ClusterManager: c.clusterManager, - GitOpsManager: c.gitOpsManager, - ClusterSpec: clusterSpec, - Writer: c.writer, - Validations: validator, - EksdInstaller: c.eksdInstaller, - PackageInstaller: c.packageInstaller, - } - - if clusterSpec.ManagementCluster != nil { - commandContext.BootstrapCluster = clusterSpec.ManagementCluster - } - - err := task.NewTaskRunner(&SetAndValidateTask{}, c.writer).RunTask(ctx, commandContext) - - return err -} - -// task related entities - -type CreateBootStrapClusterTask struct{} - -type SetAndValidateTask struct{} - -type CreateWorkloadClusterTask struct{} - -type InstallResourcesOnManagementTask struct{} - -type InstallEksaComponentsTask struct{} - -type InstallGitOpsManagerTask struct{} - -type MoveClusterManagementTask struct{} - -type WriteClusterConfigTask struct{} - -type DeleteBootstrapClusterTask struct { - *CollectDiagnosticsTask -} - -type InstallCuratedPackagesTask struct{} - -// CreateBootStrapClusterTask implementation - -func (s *CreateBootStrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - if commandContext.BootstrapCluster != nil { - if commandContext.ClusterSpec.AWSIamConfig != nil { - logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") - if err := commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { - commandContext.SetError(err) - return &CollectMgmtClusterDiagnosticsTask{} - } - } - - return &CreateWorkloadClusterTask{} - } - logger.Info("Creating new bootstrap cluster") - - bootstrapOptions, err := commandContext.Provider.BootstrapClusterOpts(commandContext.ClusterSpec) - if err != nil { - commandContext.SetError(err) - return nil - } - - bootstrapCluster, err := commandContext.Bootstrapper.CreateBootstrapCluster(ctx, commandContext.ClusterSpec, bootstrapOptions...) - if err != nil { - commandContext.SetError(err) - return nil - } - commandContext.BootstrapCluster = bootstrapCluster - - logger.Info("Provider specific pre-capi-install-setup on bootstrap cluster") - if err = commandContext.Provider.PreCAPIInstallOnBootstrap(ctx, bootstrapCluster, commandContext.ClusterSpec); err != nil { - commandContext.SetError(err) - return &CollectMgmtClusterDiagnosticsTask{} - } - - logger.Info("Installing cluster-api providers on bootstrap cluster") - if err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, bootstrapCluster, commandContext.Provider); err != nil { - commandContext.SetError(err) - return &CollectMgmtClusterDiagnosticsTask{} - } - - if commandContext.ClusterSpec.AWSIamConfig != nil { - logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") - if err = commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, bootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { - commandContext.SetError(err) - return &CollectMgmtClusterDiagnosticsTask{} - } - } - - logger.Info("Provider specific post-setup") - if err = commandContext.Provider.PostBootstrapSetup(ctx, commandContext.ClusterSpec.Cluster, bootstrapCluster); err != nil { - commandContext.SetError(err) - return &CollectMgmtClusterDiagnosticsTask{} - } - - return &CreateWorkloadClusterTask{} -} - -func (s *CreateBootStrapClusterTask) Name() string { - return "bootstrap-cluster-init" -} - -func (s *CreateBootStrapClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *CreateBootStrapClusterTask) Checkpoint() *task.CompletedTask { - return nil -} - -// SetAndValidateTask implementation - -func (s *SetAndValidateTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - logger.Info("Performing setup and validations") - runner := validations.NewRunner() - runner.Register(s.providerValidation(ctx, commandContext)...) - runner.Register(commandContext.GitOpsManager.Validations(ctx, commandContext.ClusterSpec)...) - runner.Register(commandContext.Validations.PreflightValidations(ctx)...) - - err := runner.Run() - if err != nil { - commandContext.SetError(err) - return nil - } - return &CreateBootStrapClusterTask{} -} - -func (s *SetAndValidateTask) providerValidation(ctx context.Context, commandContext *task.CommandContext) []validations.Validation { - return []validations.Validation{ - func() *validations.ValidationResult { - return &validations.ValidationResult{ - Name: fmt.Sprintf("%s Provider setup is valid", commandContext.Provider.Name()), - Err: commandContext.Provider.SetupAndValidateCreateCluster(ctx, commandContext.ClusterSpec), - } - }, - } -} - -func (s *SetAndValidateTask) Name() string { - return "setup-validate" -} - -func (s *SetAndValidateTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *SetAndValidateTask) Checkpoint() *task.CompletedTask { - return nil -} - -// CreateWorkloadClusterTask implementation - -func (s *CreateWorkloadClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - logger.Info("Creating new workload cluster") - workloadCluster, err := commandContext.ClusterManager.CreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - commandContext.WorkloadCluster = workloadCluster - - logger.Info("Installing networking on workload cluster") - err = commandContext.ClusterManager.InstallNetworking(ctx, workloadCluster, commandContext.ClusterSpec, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - logger.V(4).Info("Installing machine health checks on bootstrap cluster") - err = commandContext.ClusterManager.InstallMachineHealthChecks(ctx, commandContext.ClusterSpec, commandContext.BootstrapCluster) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - if err = commandContext.ClusterManager.RunPostCreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - if commandContext.ClusterSpec.AWSIamConfig != nil { - logger.Info("Installing aws-iam-authenticator on workload cluster") - err = commandContext.ClusterManager.InstallAwsIamAuth(ctx, commandContext.BootstrapCluster, workloadCluster, commandContext.ClusterSpec) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - } - - if !commandContext.BootstrapCluster.ExistingManagement { - logger.Info("Creating EKS-A namespace") - err = commandContext.ClusterManager.CreateEKSANamespace(ctx, workloadCluster) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - logger.Info("Installing cluster-api providers on workload cluster") - err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - logger.Info("Installing EKS-A secrets on workload cluster") - err := commandContext.Provider.UpdateSecrets(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - } - - return &InstallResourcesOnManagementTask{} -} - -func (s *CreateWorkloadClusterTask) Name() string { - return "workload-cluster-init" -} - -func (s *CreateWorkloadClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *CreateWorkloadClusterTask) Checkpoint() *task.CompletedTask { - return nil -} - -// InstallResourcesOnManagement implementation. -func (s *InstallResourcesOnManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - if commandContext.BootstrapCluster.ExistingManagement { - return &MoveClusterManagementTask{} - } - logger.Info("Installing resources on management cluster") - - if err := commandContext.Provider.PostWorkloadInit(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - return &MoveClusterManagementTask{} -} - -func (s *InstallResourcesOnManagementTask) Name() string { - return "install-resources-on-management-cluster" -} - -func (s *InstallResourcesOnManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *InstallResourcesOnManagementTask) Checkpoint() *task.CompletedTask { - return nil -} - -// MoveClusterManagementTask implementation - -func (s *MoveClusterManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - if commandContext.BootstrapCluster.ExistingManagement { - return &InstallEksaComponentsTask{} - } - logger.Info("Moving cluster management from bootstrap to workload cluster") - err := commandContext.ClusterManager.MoveCAPI(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef()) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - - return &InstallEksaComponentsTask{} -} - -func (s *MoveClusterManagementTask) Name() string { - return "capi-management-move" -} - -func (s *MoveClusterManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *MoveClusterManagementTask) Checkpoint() *task.CompletedTask { - return nil -} - -// InstallEksaComponentsTask implementation - -func (s *InstallEksaComponentsTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - if !commandContext.BootstrapCluster.ExistingManagement { - logger.Info("Installing EKS-A custom components (CRD and controller) on workload cluster") - err := commandContext.ClusterManager.InstallCustomComponents(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - logger.Info("Installing EKS-D components on workload cluster") - err = commandContext.EksdInstaller.InstallEksdCRDs(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - } - - logger.Info("Creating EKS-A CRDs instances on workload cluster") - datacenterConfig := commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec) - machineConfigs := commandContext.Provider.MachineConfigs(commandContext.ClusterSpec) - - targetCluster := commandContext.WorkloadCluster - if commandContext.BootstrapCluster.ExistingManagement { - targetCluster = commandContext.BootstrapCluster - } - err := commandContext.ClusterManager.CreateEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - err = commandContext.EksdInstaller.InstallEksdManifest(ctx, commandContext.ClusterSpec, targetCluster) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - return &InstallGitOpsManagerTask{} -} - -func (s *InstallEksaComponentsTask) Name() string { - return "eksa-components-install" -} - -func (s *InstallEksaComponentsTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *InstallEksaComponentsTask) Checkpoint() *task.CompletedTask { - return nil -} - -// InstallGitOpsManagerTask implementation - -func (s *InstallGitOpsManagerTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - logger.Info("Installing GitOps Toolkit on workload cluster") - - err := commandContext.GitOpsManager.InstallGitOps(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec)) - if err != nil { - logger.MarkFail("Error when installing GitOps toolkits on workload cluster; EKS-A will continue with cluster creation, but GitOps will not be enabled", "error", err) - return &WriteClusterConfigTask{} - } - return &WriteClusterConfigTask{} -} - -func (s *InstallGitOpsManagerTask) Name() string { - return "gitops-manager-install" -} - -func (s *InstallGitOpsManagerTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *InstallGitOpsManagerTask) Checkpoint() *task.CompletedTask { - return nil -} - -func (s *WriteClusterConfigTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - logger.Info("Writing cluster config file") - err := clustermarshaller.WriteClusterConfig(commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec), commandContext.Writer) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } - return &DeleteBootstrapClusterTask{} -} - -func (s *WriteClusterConfigTask) Name() string { - return "write-cluster-config" -} - -func (s *WriteClusterConfigTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *WriteClusterConfigTask) Checkpoint() *task.CompletedTask { - return nil -} - -// DeleteBootstrapClusterTask implementation - -func (s *DeleteBootstrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - if !commandContext.BootstrapCluster.ExistingManagement { - logger.Info("Deleting bootstrap cluster") - err := commandContext.Bootstrapper.DeleteBootstrapCluster(ctx, commandContext.BootstrapCluster, constants.Create, false) - if err != nil { - commandContext.SetError(err) - } - } - if commandContext.OriginalError == nil { - logger.MarkSuccess("Cluster created!") - } - return &InstallCuratedPackagesTask{} -} - -func (s *DeleteBootstrapClusterTask) Name() string { - return "delete-kind-cluster" -} - -func (cp *InstallCuratedPackagesTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { - commandContext.PackageInstaller.InstallCuratedPackages(ctx) - return nil -} - -func (cp *InstallCuratedPackagesTask) Name() string { - return "install-curated-packages" -} - -func (s *InstallCuratedPackagesTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { - return nil, nil -} - -func (s *InstallCuratedPackagesTask) Checkpoint() *task.CompletedTask { - return nil -} +// import ( +// "context" +// "fmt" + +// "github.com/aws/eks-anywhere/pkg/cluster" +// "github.com/aws/eks-anywhere/pkg/clustermarshaller" +// "github.com/aws/eks-anywhere/pkg/constants" +// "github.com/aws/eks-anywhere/pkg/filewriter" +// "github.com/aws/eks-anywhere/pkg/logger" +// "github.com/aws/eks-anywhere/pkg/providers" +// "github.com/aws/eks-anywhere/pkg/task" +// "github.com/aws/eks-anywhere/pkg/types" +// "github.com/aws/eks-anywhere/pkg/validations" +// "github.com/aws/eks-anywhere/pkg/workflows/interfaces" +// ) + +// type Create struct { +// bootstrapper interfaces.Bootstrapper +// provider providers.Provider +// clusterManager interfaces.ClusterManager +// gitOpsManager interfaces.GitOpsManager +// writer filewriter.FileWriter +// eksdInstaller interfaces.EksdInstaller +// packageInstaller interfaces.PackageInstaller +// } + +// func NewCreate(bootstrapper interfaces.Bootstrapper, provider providers.Provider, +// clusterManager interfaces.ClusterManager, gitOpsManager interfaces.GitOpsManager, +// writer filewriter.FileWriter, eksdInstaller interfaces.EksdInstaller, +// packageInstaller interfaces.PackageInstaller, +// ) *Create { +// return &Create{ +// bootstrapper: bootstrapper, +// provider: provider, +// clusterManager: clusterManager, +// gitOpsManager: gitOpsManager, +// writer: writer, +// eksdInstaller: eksdInstaller, +// packageInstaller: packageInstaller, +// } +// } + +// func (c *Create) Run(ctx context.Context, clusterSpec *cluster.Spec, validator interfaces.Validator, forceCleanup bool) error { +// if forceCleanup { +// if err := c.bootstrapper.DeleteBootstrapCluster(ctx, &types.Cluster{ +// Name: clusterSpec.Cluster.Name, +// }, constants.Create, forceCleanup); err != nil { +// return err +// } +// } +// commandContext := &task.CommandContext{ +// Bootstrapper: c.bootstrapper, +// Provider: c.provider, +// ClusterManager: c.clusterManager, +// GitOpsManager: c.gitOpsManager, +// ClusterSpec: clusterSpec, +// Writer: c.writer, +// Validations: validator, +// EksdInstaller: c.eksdInstaller, +// PackageInstaller: c.packageInstaller, +// } + +// if clusterSpec.ManagementCluster != nil { +// commandContext.BootstrapCluster = clusterSpec.ManagementCluster +// } + +// err := task.NewTaskRunner(&SetAndValidateTask{}, c.writer).RunTask(ctx, commandContext) + +// return err +// } + +// // task related entities + +// type CreateBootStrapClusterTask struct{} + +// type SetAndValidateTask struct{} + +// type CreateWorkloadClusterTask struct{} + +// type InstallResourcesOnManagementTask struct{} + +// type InstallEksaComponentsTask struct{} + +// type InstallGitOpsManagerTask struct{} + +// type MoveClusterManagementTask struct{} + +// type WriteClusterConfigTask struct{} + +// type DeleteBootstrapClusterTask struct { +// *CollectDiagnosticsTask +// } + +// type InstallCuratedPackagesTask struct{} + +// // CreateBootStrapClusterTask implementation + +// func (s *CreateBootStrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// if commandContext.BootstrapCluster != nil { +// if commandContext.ClusterSpec.AWSIamConfig != nil { +// logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") +// if err := commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { +// commandContext.SetError(err) +// return &CollectMgmtClusterDiagnosticsTask{} +// } +// } + +// return &CreateWorkloadClusterTask{} +// } +// logger.Info("Creating new bootstrap cluster") + +// bootstrapOptions, err := commandContext.Provider.BootstrapClusterOpts(commandContext.ClusterSpec) +// if err != nil { +// commandContext.SetError(err) +// return nil +// } + +// bootstrapCluster, err := commandContext.Bootstrapper.CreateBootstrapCluster(ctx, commandContext.ClusterSpec, bootstrapOptions...) +// if err != nil { +// commandContext.SetError(err) +// return nil +// } +// commandContext.BootstrapCluster = bootstrapCluster + +// logger.Info("Provider specific pre-capi-install-setup on bootstrap cluster") +// if err = commandContext.Provider.PreCAPIInstallOnBootstrap(ctx, bootstrapCluster, commandContext.ClusterSpec); err != nil { +// commandContext.SetError(err) +// return &CollectMgmtClusterDiagnosticsTask{} +// } + +// logger.Info("Installing cluster-api providers on bootstrap cluster") +// if err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, bootstrapCluster, commandContext.Provider); err != nil { +// commandContext.SetError(err) +// return &CollectMgmtClusterDiagnosticsTask{} +// } + +// if commandContext.ClusterSpec.AWSIamConfig != nil { +// logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") +// if err = commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, bootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { +// commandContext.SetError(err) +// return &CollectMgmtClusterDiagnosticsTask{} +// } +// } + +// logger.Info("Provider specific post-setup") +// if err = commandContext.Provider.PostBootstrapSetup(ctx, commandContext.ClusterSpec.Cluster, bootstrapCluster); err != nil { +// commandContext.SetError(err) +// return &CollectMgmtClusterDiagnosticsTask{} +// } + +// return &CreateWorkloadClusterTask{} +// } + +// func (s *CreateBootStrapClusterTask) Name() string { +// return "bootstrap-cluster-init" +// } + +// func (s *CreateBootStrapClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *CreateBootStrapClusterTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // SetAndValidateTask implementation + +// func (s *SetAndValidateTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// logger.Info("Performing setup and validations") +// runner := validations.NewRunner() +// runner.Register(s.providerValidation(ctx, commandContext)...) +// runner.Register(commandContext.GitOpsManager.Validations(ctx, commandContext.ClusterSpec)...) +// runner.Register(commandContext.Validations.PreflightValidations(ctx)...) + +// err := runner.Run() +// if err != nil { +// commandContext.SetError(err) +// return nil +// } +// return &CreateBootStrapClusterTask{} +// } + +// func (s *SetAndValidateTask) providerValidation(ctx context.Context, commandContext *task.CommandContext) []validations.Validation { +// return []validations.Validation{ +// func() *validations.ValidationResult { +// return &validations.ValidationResult{ +// Name: fmt.Sprintf("%s Provider setup is valid", commandContext.Provider.Name()), +// Err: commandContext.Provider.SetupAndValidateCreateCluster(ctx, commandContext.ClusterSpec), +// } +// }, +// } +// } + +// func (s *SetAndValidateTask) Name() string { +// return "setup-validate" +// } + +// func (s *SetAndValidateTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *SetAndValidateTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // CreateWorkloadClusterTask implementation + +// func (s *CreateWorkloadClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// logger.Info("Creating new workload cluster") +// workloadCluster, err := commandContext.ClusterManager.CreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec, commandContext.Provider) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// commandContext.WorkloadCluster = workloadCluster + +// logger.Info("Installing networking on workload cluster") +// err = commandContext.ClusterManager.InstallNetworking(ctx, workloadCluster, commandContext.ClusterSpec, commandContext.Provider) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// logger.V(4).Info("Installing machine health checks on bootstrap cluster") +// err = commandContext.ClusterManager.InstallMachineHealthChecks(ctx, commandContext.ClusterSpec, commandContext.BootstrapCluster) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// if err = commandContext.ClusterManager.RunPostCreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// if commandContext.ClusterSpec.AWSIamConfig != nil { +// logger.Info("Installing aws-iam-authenticator on workload cluster") +// err = commandContext.ClusterManager.InstallAwsIamAuth(ctx, commandContext.BootstrapCluster, workloadCluster, commandContext.ClusterSpec) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// } + +// if !commandContext.BootstrapCluster.ExistingManagement { +// logger.Info("Creating EKS-A namespace") +// err = commandContext.ClusterManager.CreateEKSANamespace(ctx, workloadCluster) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// logger.Info("Installing cluster-api providers on workload cluster") +// err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// logger.Info("Installing EKS-A secrets on workload cluster") +// err := commandContext.Provider.UpdateSecrets(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// } + +// return &InstallResourcesOnManagementTask{} +// } + +// func (s *CreateWorkloadClusterTask) Name() string { +// return "workload-cluster-init" +// } + +// func (s *CreateWorkloadClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *CreateWorkloadClusterTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // InstallResourcesOnManagement implementation. +// func (s *InstallResourcesOnManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// if commandContext.BootstrapCluster.ExistingManagement { +// return &MoveClusterManagementTask{} +// } +// logger.Info("Installing resources on management cluster") + +// if err := commandContext.Provider.PostWorkloadInit(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// return &MoveClusterManagementTask{} +// } + +// func (s *InstallResourcesOnManagementTask) Name() string { +// return "install-resources-on-management-cluster" +// } + +// func (s *InstallResourcesOnManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *InstallResourcesOnManagementTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // MoveClusterManagementTask implementation + +// func (s *MoveClusterManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// if commandContext.BootstrapCluster.ExistingManagement { +// return &InstallEksaComponentsTask{} +// } +// logger.Info("Moving cluster management from bootstrap to workload cluster") +// err := commandContext.ClusterManager.MoveCAPI(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef()) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } + +// return &InstallEksaComponentsTask{} +// } + +// func (s *MoveClusterManagementTask) Name() string { +// return "capi-management-move" +// } + +// func (s *MoveClusterManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *MoveClusterManagementTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // InstallEksaComponentsTask implementation + +// func (s *InstallEksaComponentsTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// if !commandContext.BootstrapCluster.ExistingManagement { +// logger.Info("Installing EKS-A custom components (CRD and controller) on workload cluster") +// err := commandContext.ClusterManager.InstallCustomComponents(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// logger.Info("Installing EKS-D components on workload cluster") +// err = commandContext.EksdInstaller.InstallEksdCRDs(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// } + +// logger.Info("Creating EKS-A CRDs instances on workload cluster") +// datacenterConfig := commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec) +// machineConfigs := commandContext.Provider.MachineConfigs(commandContext.ClusterSpec) + +// targetCluster := commandContext.WorkloadCluster +// if commandContext.BootstrapCluster.ExistingManagement { +// targetCluster = commandContext.BootstrapCluster +// } +// err := commandContext.ClusterManager.CreateEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// err = commandContext.EksdInstaller.InstallEksdManifest(ctx, commandContext.ClusterSpec, targetCluster) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// return &InstallGitOpsManagerTask{} +// } + +// func (s *InstallEksaComponentsTask) Name() string { +// return "eksa-components-install" +// } + +// func (s *InstallEksaComponentsTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *InstallEksaComponentsTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // InstallGitOpsManagerTask implementation + +// func (s *InstallGitOpsManagerTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// logger.Info("Installing GitOps Toolkit on workload cluster") + +// err := commandContext.GitOpsManager.InstallGitOps(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec)) +// if err != nil { +// logger.MarkFail("Error when installing GitOps toolkits on workload cluster; EKS-A will continue with cluster creation, but GitOps will not be enabled", "error", err) +// return &WriteClusterConfigTask{} +// } +// return &WriteClusterConfigTask{} +// } + +// func (s *InstallGitOpsManagerTask) Name() string { +// return "gitops-manager-install" +// } + +// func (s *InstallGitOpsManagerTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *InstallGitOpsManagerTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// func (s *WriteClusterConfigTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// logger.Info("Writing cluster config file") +// err := clustermarshaller.WriteClusterConfig(commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec), commandContext.Writer) +// if err != nil { +// commandContext.SetError(err) +// return &CollectDiagnosticsTask{} +// } +// return &DeleteBootstrapClusterTask{} +// } + +// func (s *WriteClusterConfigTask) Name() string { +// return "write-cluster-config" +// } + +// func (s *WriteClusterConfigTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *WriteClusterConfigTask) Checkpoint() *task.CompletedTask { +// return nil +// } + +// // DeleteBootstrapClusterTask implementation + +// func (s *DeleteBootstrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// if !commandContext.BootstrapCluster.ExistingManagement { +// logger.Info("Deleting bootstrap cluster") +// err := commandContext.Bootstrapper.DeleteBootstrapCluster(ctx, commandContext.BootstrapCluster, constants.Create, false) +// if err != nil { +// commandContext.SetError(err) +// } +// } +// if commandContext.OriginalError == nil { +// logger.MarkSuccess("Cluster created!") +// } +// return &InstallCuratedPackagesTask{} +// } + +// func (s *DeleteBootstrapClusterTask) Name() string { +// return "delete-kind-cluster" +// } + +// func (cp *InstallCuratedPackagesTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { +// commandContext.PackageInstaller.InstallCuratedPackages(ctx) +// return nil +// } + +// func (cp *InstallCuratedPackagesTask) Name() string { +// return "install-curated-packages" +// } + +// func (s *InstallCuratedPackagesTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { +// return nil, nil +// } + +// func (s *InstallCuratedPackagesTask) Checkpoint() *task.CompletedTask { +// return nil +// } diff --git a/pkg/workflows/create_mgmt_poc.go b/pkg/workflows/create_mgmt_poc.go new file mode 100644 index 000000000000..8e4c81877e0c --- /dev/null +++ b/pkg/workflows/create_mgmt_poc.go @@ -0,0 +1,555 @@ +package workflows + +import ( + "context" + "fmt" + + "github.com/aws/eks-anywhere/pkg/cluster" + "github.com/aws/eks-anywhere/pkg/clustermarshaller" + "github.com/aws/eks-anywhere/pkg/constants" + "github.com/aws/eks-anywhere/pkg/filewriter" + "github.com/aws/eks-anywhere/pkg/logger" + "github.com/aws/eks-anywhere/pkg/providers" + "github.com/aws/eks-anywhere/pkg/task" + "github.com/aws/eks-anywhere/pkg/types" + "github.com/aws/eks-anywhere/pkg/validations" + "github.com/aws/eks-anywhere/pkg/workflows/interfaces" +) + +type Create struct { + bootstrapper interfaces.Bootstrapper + provider providers.Provider + clusterManager interfaces.ClusterManager + gitOpsManager interfaces.GitOpsManager + writer filewriter.FileWriter + eksdInstaller interfaces.EksdInstaller + packageInstaller interfaces.PackageInstaller + clusterUpgrader interfaces.ClusterUpgrader +} + +func NewCreate(bootstrapper interfaces.Bootstrapper, provider providers.Provider, + clusterManager interfaces.ClusterManager, gitOpsManager interfaces.GitOpsManager, + writer filewriter.FileWriter, eksdInstaller interfaces.EksdInstaller, + packageInstaller interfaces.PackageInstaller, + clusterUpgrade interfaces.ClusterUpgrader, +) *Create { + return &Create{ + bootstrapper: bootstrapper, + provider: provider, + clusterManager: clusterManager, + gitOpsManager: gitOpsManager, + writer: writer, + eksdInstaller: eksdInstaller, + packageInstaller: packageInstaller, + clusterUpgrader: clusterUpgrade, + } +} + +func (c *Create) Run(ctx context.Context, clusterSpec *cluster.Spec, validator interfaces.Validator, forceCleanup bool) error { + if forceCleanup { + if err := c.bootstrapper.DeleteBootstrapCluster(ctx, &types.Cluster{ + Name: clusterSpec.Cluster.Name, + }, constants.Create, forceCleanup); err != nil { + return err + } + } + commandContext := &task.CommandContext{ + Bootstrapper: c.bootstrapper, + Provider: c.provider, + ClusterManager: c.clusterManager, + GitOpsManager: c.gitOpsManager, + ClusterSpec: clusterSpec, + Writer: c.writer, + Validations: validator, + EksdInstaller: c.eksdInstaller, + PackageInstaller: c.packageInstaller, + ClusterUpgrader: c.clusterUpgrader, + } + + if clusterSpec.ManagementCluster != nil { + commandContext.BootstrapCluster = clusterSpec.ManagementCluster + } + + err := task.NewTaskRunner(&SetAndValidateTask{}, c.writer).RunTask(ctx, commandContext) + + return err +} + +// task related entities + +type CreateBootStrapClusterTask struct{} + +type SetAndValidateTask struct{} + +type CreateWorkloadClusterTask struct{} + +type InstallResourcesOnManagementTask struct{} + +type InstallEksaComponentsTask struct{} + +type InstallGitOpsManagerTask struct{} + +type MoveClusterManagementTask struct{} + +type InstallEksaComponentsOnWorkloadTask struct{} + +type WriteClusterConfigTask struct{} + +type DeleteBootstrapClusterTask struct { + *CollectDiagnosticsTask +} + +type InstallCuratedPackagesTask struct{} + +// SetAndValidateTask implementation + +func (s *SetAndValidateTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + logger.Info("Performing setup and validations") + runner := validations.NewRunner() + runner.Register(s.providerValidation(ctx, commandContext)...) + runner.Register(commandContext.GitOpsManager.Validations(ctx, commandContext.ClusterSpec)...) + runner.Register(commandContext.Validations.PreflightValidations(ctx)...) + + err := runner.Run() + if err != nil { + commandContext.SetError(err) + return nil + } + return &CreateBootStrapClusterTask{} +} + +func (s *SetAndValidateTask) providerValidation(ctx context.Context, commandContext *task.CommandContext) []validations.Validation { + return []validations.Validation{ + func() *validations.ValidationResult { + return &validations.ValidationResult{ + Name: fmt.Sprintf("%s Provider setup is valid", commandContext.Provider.Name()), + Err: commandContext.Provider.SetupAndValidateCreateCluster(ctx, commandContext.ClusterSpec), + } + }, + } +} + +func (s *SetAndValidateTask) Name() string { + return "setup-validate" +} + +func (s *SetAndValidateTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *SetAndValidateTask) Checkpoint() *task.CompletedTask { + return nil +} + +// CreateBootStrapClusterTask implementation + +func (s *CreateBootStrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if commandContext.BootstrapCluster != nil { + if commandContext.ClusterSpec.AWSIamConfig != nil { + logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") + if err := commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + } + + return &CreateWorkloadClusterTask{} + } + logger.Info("Creating new bootstrap cluster") + + bootstrapOptions, err := commandContext.Provider.BootstrapClusterOpts(commandContext.ClusterSpec) + if err != nil { + commandContext.SetError(err) + return nil + } + + bootstrapCluster, err := commandContext.Bootstrapper.CreateBootstrapCluster(ctx, commandContext.ClusterSpec, bootstrapOptions...) + if err != nil { + commandContext.SetError(err) + return nil + } + commandContext.BootstrapCluster = bootstrapCluster + + logger.Info("Provider specific pre-capi-install-setup on bootstrap cluster") + if err = commandContext.Provider.PreCAPIInstallOnBootstrap(ctx, bootstrapCluster, commandContext.ClusterSpec); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + + logger.Info("Installing cluster-api providers on bootstrap cluster") + if err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, bootstrapCluster, commandContext.Provider); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + + if commandContext.ClusterSpec.AWSIamConfig != nil { + logger.Info("Creating aws-iam-authenticator certificate and key pair secret on bootstrap cluster") + if err = commandContext.ClusterManager.CreateAwsIamAuthCaSecret(ctx, bootstrapCluster, commandContext.ClusterSpec.Cluster.Name); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + } + + logger.Info("Provider specific post-setup") + if err = commandContext.Provider.PostBootstrapSetup(ctx, commandContext.ClusterSpec.Cluster, bootstrapCluster); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + + return &InstallEksaComponentsTask{} +} + +func (s *CreateBootStrapClusterTask) Name() string { + return "bootstrap-cluster-init" +} + +func (s *CreateBootStrapClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *CreateBootStrapClusterTask) Checkpoint() *task.CompletedTask { + return nil +} + +// InstallEksaComponentsTask implementation + +func (s *InstallEksaComponentsTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if !commandContext.BootstrapCluster.ExistingManagement { + logger.Info("Installing EKS-A custom components (CRD and controller) on workload cluster") + err := commandContext.ClusterManager.InstallCustomComponents(ctx, commandContext.ClusterSpec, commandContext.BootstrapCluster, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + logger.Info("Installing EKS-D components on workload cluster") + err = commandContext.EksdInstaller.InstallEksdCRDs(ctx, commandContext.ClusterSpec, commandContext.BootstrapCluster) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + } + + logger.Info("Creating EKS-A CRDs instances on workload cluster") + datacenterConfig := commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec) + machineConfigs := commandContext.Provider.MachineConfigs(commandContext.ClusterSpec) + + targetCluster := commandContext.BootstrapCluster + // if commandContext.BootstrapCluster.ExistingManagement { + // fmt.Println("IN BOOTSTRAP") + // targetCluster = commandContext.BootstrapCluster + // } + err := commandContext.ClusterManager.CreateEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + err = commandContext.EksdInstaller.InstallEksdManifest(ctx, commandContext.ClusterSpec, targetCluster) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + + logger.Info("Applying to management cluster") + if err := commandContext.ClusterUpgrader.Run(ctx, commandContext.ClusterSpec, *targetCluster); err != nil { + commandContext.SetError(err) + return &CollectMgmtClusterDiagnosticsTask{} + } + + // err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) + // if err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } + return &CreateWorkloadClusterTask{} +} + +func (s *InstallEksaComponentsTask) Name() string { + return "eksa-components-install" +} + +func (s *InstallEksaComponentsTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *InstallEksaComponentsTask) Checkpoint() *task.CompletedTask { + return nil +} + +// CreateWorkloadClusterTask implementation + +func (s *CreateWorkloadClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + logger.Info("Creating new workload cluster") + workloadCluster, err := commandContext.ClusterManager.CreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.ClusterSpec, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + commandContext.WorkloadCluster = workloadCluster + + // logger.Info("Installing networking on workload cluster") + // err = commandContext.ClusterManager.InstallNetworking(ctx, workloadCluster, commandContext.ClusterSpec, commandContext.Provider) + // if err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } + + // logger.V(4).Info("Installing machine health checks on bootstrap cluster") + // err = commandContext.ClusterManager.InstallMachineHealthChecks(ctx, commandContext.ClusterSpec, commandContext.BootstrapCluster) + // if err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } + + // if err = commandContext.ClusterManager.RunPostCreateWorkloadCluster(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } + + // if commandContext.ClusterSpec.AWSIamConfig != nil { + // logger.Info("Installing aws-iam-authenticator on workload cluster") + // err = commandContext.ClusterManager.InstallAwsIamAuth(ctx, commandContext.BootstrapCluster, workloadCluster, commandContext.ClusterSpec) + // if err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } + // } + + // time.Sleep(20 * time.Minute) + + if !commandContext.BootstrapCluster.ExistingManagement { + logger.Info("Creating EKS-A namespace") + err := commandContext.ClusterManager.CreateEKSANamespace(ctx, commandContext.WorkloadCluster) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + + logger.Info("Installing cluster-api providers on workload cluster") + err = commandContext.ClusterManager.InstallCAPI(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + + logger.Info("Installing EKS-A secrets on workload cluster") + err = commandContext.Provider.UpdateSecrets(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + } + + return &InstallResourcesOnManagementTask{} +} + +func (s *CreateWorkloadClusterTask) Name() string { + return "workload-cluster-init" +} + +func (s *CreateWorkloadClusterTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *CreateWorkloadClusterTask) Checkpoint() *task.CompletedTask { + return nil +} + +// InstallResourcesOnManagement implementation. +func (s *InstallResourcesOnManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if commandContext.BootstrapCluster.ExistingManagement { + return &MoveClusterManagementTask{} + } + logger.Info("Installing resources on management cluster") + + if err := commandContext.Provider.PostWorkloadInit(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec); err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + return &MoveClusterManagementTask{} +} + +func (s *InstallResourcesOnManagementTask) Name() string { + return "install-resources-on-management-cluster" +} + +func (s *InstallResourcesOnManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *InstallResourcesOnManagementTask) Checkpoint() *task.CompletedTask { + return nil +} + +// MoveClusterManagementTask implementation + +func (s *MoveClusterManagementTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if commandContext.BootstrapCluster.ExistingManagement { + return &InstallEksaComponentsOnWorkloadTask{} + } + logger.Info("Moving cluster management from bootstrap to workload cluster") + err := commandContext.ClusterManager.MoveCAPI(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef()) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + + return &InstallEksaComponentsOnWorkloadTask{} +} + +func (s *MoveClusterManagementTask) Name() string { + return "capi-management-move" +} + +func (s *MoveClusterManagementTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *MoveClusterManagementTask) Checkpoint() *task.CompletedTask { + return nil +} + + +// InstallEksaComponentsOnWorkloadTask implementation + +func (s *InstallEksaComponentsOnWorkloadTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if !commandContext.BootstrapCluster.ExistingManagement { + logger.Info("Installing EKS-A custom components (CRD and controller) on workload cluster") + err := commandContext.ClusterManager.InstallCustomComponents(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + logger.Info("Installing EKS-D components on workload cluster") + err = commandContext.EksdInstaller.InstallEksdCRDs(ctx, commandContext.ClusterSpec, commandContext.WorkloadCluster) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + } + + logger.Info("Creating EKS-A CRDs instances on workload cluster") + datacenterConfig := commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec) + machineConfigs := commandContext.Provider.MachineConfigs(commandContext.ClusterSpec) + + targetCluster := commandContext.WorkloadCluster + fmt.Println("BEFORE BOOTSTRAP") + + // if commandContext.BootstrapCluster.ExistingManagement { + // fmt.Println("IN BOOTSTRAP") + + // targetCluster = commandContext.BootstrapCluster + // } + fmt.Println("AFTER BOOTSTRAP") + + err := commandContext.ClusterManager.CreateEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + err = commandContext.EksdInstaller.InstallEksdManifest(ctx, commandContext.ClusterSpec, targetCluster) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + return &InstallGitOpsManagerTask{} +} + +func (s *InstallEksaComponentsOnWorkloadTask) Name() string { + return "eksa-components-workload-install" +} + +func (s *InstallEksaComponentsOnWorkloadTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *InstallEksaComponentsOnWorkloadTask) Checkpoint() *task.CompletedTask { + return nil +} +// InstallGitOpsManagerTask implementation + +func (s *InstallGitOpsManagerTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + logger.Info("Installing GitOps Toolkit on workload cluster") + + err := commandContext.GitOpsManager.InstallGitOps(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec)) + if err != nil { + logger.MarkFail("Error when installing GitOps toolkits on workload cluster; EKS-A will continue with cluster creation, but GitOps will not be enabled", "error", err) + return &WriteClusterConfigTask{} + } + return &WriteClusterConfigTask{} +} + +func (s *InstallGitOpsManagerTask) Name() string { + return "gitops-manager-install" +} + +func (s *InstallGitOpsManagerTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *InstallGitOpsManagerTask) Checkpoint() *task.CompletedTask { + return nil +} + +func (s *WriteClusterConfigTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + logger.Info("Writing cluster config file") + err := clustermarshaller.WriteClusterConfig(commandContext.ClusterSpec, commandContext.Provider.DatacenterConfig(commandContext.ClusterSpec), commandContext.Provider.MachineConfigs(commandContext.ClusterSpec), commandContext.Writer) + if err != nil { + commandContext.SetError(err) + return &CollectDiagnosticsTask{} + } + return &DeleteBootstrapClusterTask{} +} + +func (s *WriteClusterConfigTask) Name() string { + return "write-cluster-config" +} + +func (s *WriteClusterConfigTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *WriteClusterConfigTask) Checkpoint() *task.CompletedTask { + return nil +} + +// DeleteBootstrapClusterTask implementation + +func (s *DeleteBootstrapClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + if !commandContext.BootstrapCluster.ExistingManagement { + logger.Info("Deleting bootstrap cluster") + err := commandContext.Bootstrapper.DeleteBootstrapCluster(ctx, commandContext.BootstrapCluster, constants.Create, false) + if err != nil { + commandContext.SetError(err) + } + } + if commandContext.OriginalError == nil { + logger.MarkSuccess("Cluster created!") + } + return &InstallCuratedPackagesTask{} +} + +func (s *DeleteBootstrapClusterTask) Name() string { + return "delete-kind-cluster" +} + +func (cp *InstallCuratedPackagesTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + commandContext.PackageInstaller.InstallCuratedPackages(ctx) + return nil +} + +func (cp *InstallCuratedPackagesTask) Name() string { + return "install-curated-packages" +} + +func (s *InstallCuratedPackagesTask) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { + return nil, nil +} + +func (s *InstallCuratedPackagesTask) Checkpoint() *task.CompletedTask { + return nil +} From 10d3abcfa4896e2d3bd781c11a679b2d60bc3cb8 Mon Sep 17 00:00:00 2001 From: Mitali Paygude Date: Wed, 29 Nov 2023 15:18:26 -0800 Subject: [PATCH 3/4] m --- pkg/clustermanager/cluster_manager.go | 32 ++++++++++++++++++++++++++ pkg/workflows/create_mgmt_poc.go | 12 +++++----- pkg/workflows/interfaces/interfaces.go | 2 ++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/pkg/clustermanager/cluster_manager.go b/pkg/clustermanager/cluster_manager.go index 1aff49fee8a8..0951937ba31b 100644 --- a/pkg/clustermanager/cluster_manager.go +++ b/pkg/clustermanager/cluster_manager.go @@ -26,6 +26,8 @@ import ( "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/clustermanager/internal" + "github.com/aws/eks-anywhere/pkg/clustermarshaller" + // "github.com/aws/eks-anywhere/pkg/clustermarshaller" "github.com/aws/eks-anywhere/pkg/constants" "github.com/aws/eks-anywhere/pkg/diagnostics" @@ -1170,6 +1172,36 @@ func (c *ClusterManager) CreateEKSAResources(ctx context.Context, cluster *types return c.ApplyReleases(ctx, clusterSpec, cluster) } +// ApplyEKSAResources applies the eks-a cluster specs (cluster, datacenterconfig, machine configs, etc.), as well as the +// release bundle to the cluster. Before applying the spec, we pause eksa controller cluster and datacenter webhook validation +// so that the cluster spec can be created or updated in the cluster without webhook validation error. +func (c *ClusterManager) ApplyEKSAResources(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, + datacenterConfig providers.DatacenterConfig, machineConfigs []providers.MachineConfig, +) error { + if clusterSpec.Cluster.Namespace != "" { + if err := c.clusterClient.CreateNamespaceIfNotPresent(ctx, cluster.KubeconfigFile, clusterSpec.Cluster.Namespace); err != nil { + return err + } + } + + // clusterSpec.Cluster.PauseReconcile() + // datacenterConfig.PauseReconcile() + + resourcesSpec, err := clustermarshaller.MarshalClusterSpec(clusterSpec, datacenterConfig, machineConfigs) + if err != nil { + return err + } + logger.V(4).Info("Applying eksa yaml resources to cluster") + logger.V(6).Info(string(resourcesSpec)) + if err = c.applyResource(ctx, cluster, resourcesSpec); err != nil { + return err + } + if err := c.ApplyBundles(ctx, clusterSpec, cluster); err != nil { + return err + } + return c.ApplyReleases(ctx, clusterSpec, cluster) +} + func (c *ClusterManager) ApplyBundles(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster) error { bundleObj, err := yaml.Marshal(clusterSpec.Bundles) if err != nil { diff --git a/pkg/workflows/create_mgmt_poc.go b/pkg/workflows/create_mgmt_poc.go index 8e4c81877e0c..16ba37cc8b35 100644 --- a/pkg/workflows/create_mgmt_poc.go +++ b/pkg/workflows/create_mgmt_poc.go @@ -441,7 +441,7 @@ func (s *InstallEksaComponentsOnWorkloadTask) Run(ctx context.Context, commandCo // } fmt.Println("AFTER BOOTSTRAP") - err := commandContext.ClusterManager.CreateEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) + err := commandContext.ClusterManager.ApplyEKSAResources(ctx, targetCluster, commandContext.ClusterSpec, datacenterConfig, machineConfigs) if err != nil { commandContext.SetError(err) return &CollectDiagnosticsTask{} @@ -451,11 +451,11 @@ func (s *InstallEksaComponentsOnWorkloadTask) Run(ctx context.Context, commandCo commandContext.SetError(err) return &CollectDiagnosticsTask{} } - err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) - if err != nil { - commandContext.SetError(err) - return &CollectDiagnosticsTask{} - } + // err = commandContext.ClusterManager.ResumeEKSAControllerReconcile(ctx, targetCluster, commandContext.ClusterSpec, commandContext.Provider) + // if err != nil { + // commandContext.SetError(err) + // return &CollectDiagnosticsTask{} + // } return &InstallGitOpsManagerTask{} } diff --git a/pkg/workflows/interfaces/interfaces.go b/pkg/workflows/interfaces/interfaces.go index fe0343fef74c..b9f00219c52a 100644 --- a/pkg/workflows/interfaces/interfaces.go +++ b/pkg/workflows/interfaces/interfaces.go @@ -34,6 +34,8 @@ type ClusterManager interface { InstallCustomComponents(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster, provider providers.Provider) error CreateEKSANamespace(ctx context.Context, cluster *types.Cluster) error CreateEKSAResources(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, datacenterConfig providers.DatacenterConfig, machineConfigs []providers.MachineConfig) error + ApplyEKSAResources(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, datacenterConfig providers.DatacenterConfig, machineConfigs []providers.MachineConfig) error + ApplyBundles(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster) error ApplyReleases(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster) error PauseEKSAControllerReconcile(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, provider providers.Provider) error From 61315750a745078184f00717dc67761953f28aff Mon Sep 17 00:00:00 2001 From: Mitali Paygude Date: Wed, 29 Nov 2023 23:19:08 -0800 Subject: [PATCH 4/4] m --- pkg/cluster/vsphere.go | 2 ++ pkg/providers/vsphere/vsphere.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/vsphere.go b/pkg/cluster/vsphere.go index ddc2de621689..a3dc5611aee5 100644 --- a/pkg/cluster/vsphere.go +++ b/pkg/cluster/vsphere.go @@ -2,6 +2,7 @@ package cluster import ( "context" + "fmt" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" ) @@ -130,6 +131,7 @@ func getVSphereMachineConfigs(ctx context.Context, client Client, c *Config) err machine := &anywherev1.VSphereMachineConfig{} if err := client.Get(ctx, machineRef.Name, c.Cluster.Namespace, machine); err != nil { + fmt.Println("INSIDE GET CALLL VSPHERE MC") return err } diff --git a/pkg/providers/vsphere/vsphere.go b/pkg/providers/vsphere/vsphere.go index 8503d19f69fc..7b2e2678b15e 100644 --- a/pkg/providers/vsphere/vsphere.go +++ b/pkg/providers/vsphere/vsphere.go @@ -971,7 +971,8 @@ func (p *vsphereProvider) createSecret(ctx context.Context, cluster *types.Clust } func (p *vsphereProvider) PreCAPIInstallOnBootstrap(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error { - return nil + // p.log.Info("Installing secrets on bootstrap cluster") + return p.UpdateSecrets(ctx, cluster, nil) } func (p *vsphereProvider) PostBootstrapSetup(ctx context.Context, clusterConfig *v1alpha1.Cluster, cluster *types.Cluster) error {