Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mgmt cluster unify CLI and controller POC #7107

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/eksctl-anywhere/cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down Expand Up @@ -211,6 +212,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er
deps.Writer,
deps.EksdInstaller,
deps.PackageInstaller,
deps.ClusterApplier,
)

validationOpts := &validations.Opts{
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/v1alpha1/cluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 2 additions & 0 deletions pkg/cluster/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cluster

import (
"context"
"fmt"

anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
)
Expand Down Expand Up @@ -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
}

Expand Down
53 changes: 44 additions & 9 deletions pkg/clustermanager/cluster_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"github.com/aws/eks-anywhere/pkg/clusterapi"
"github.com/aws/eks-anywhere/pkg/clustermanager/internal"
"github.com/aws/eks-anywhere/pkg/clustermarshaller"

Check failure on line 30 in pkg/clustermanager/cluster_manager.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with -s standard,default,prefix(github.com/aws/eks-anywhere) (gci)
// "github.com/aws/eks-anywhere/pkg/clustermarshaller"

Check failure on line 31 in pkg/clustermanager/cluster_manager.go

View workflow job for this annotation

GitHub Actions / lint

Comment should end in a period (godot)
"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/diagnostics"
"github.com/aws/eks-anywhere/pkg/executables"
Expand Down Expand Up @@ -411,13 +413,13 @@
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)

Expand Down Expand Up @@ -459,6 +461,8 @@
// 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,
Expand Down Expand Up @@ -512,6 +516,7 @@
}

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)
Expand Down Expand Up @@ -1149,8 +1154,38 @@
}
}

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 {
return err
}
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 {
Expand All @@ -1161,7 +1196,7 @@
if err = c.applyResource(ctx, cluster, resourcesSpec); err != nil {
return err
}
if err = c.ApplyBundles(ctx, clusterSpec, cluster); err != nil {
if err := c.ApplyBundles(ctx, clusterSpec, cluster); err != nil {
return err
}
return c.ApplyReleases(ctx, clusterSpec, cluster)
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading
Loading