-
Notifications
You must be signed in to change notification settings - Fork 288
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
Create management cluster using controller bootstrap task #7319
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #7319 +/- ##
==========================================
- Coverage 71.77% 71.63% -0.15%
==========================================
Files 560 562 +2
Lines 43495 43517 +22
==========================================
- Hits 31220 31173 -47
- Misses 10556 10630 +74
+ Partials 1719 1714 -5 ☔ View full report in Codecov by Sentry. |
} | ||
} | ||
|
||
clusterSpec.Cluster.AddManagedByCLIAnnotation() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition let's the webhook create management clusters using the eksa controller.
Here's that condition https://github.com/aws/eks-anywhere/blob/main/pkg/api/v1alpha1/cluster_webhook.go#L64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good point
then could we set it before applying the cluster spec? so in a different task, whichever uses the cluster creator
Also maybe add a comment since not even me remember what this was for 🤦🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I'll add it before the create workload cluster task and remove it from this PR.
@@ -523,6 +523,22 @@ func (c *ClusterManager) getWorkloadClusterKubeconfig(ctx context.Context, clust | |||
return nil | |||
} | |||
|
|||
// CreateEKSAReleaseBundle applies the eks-a release bundle to the cluster. | |||
func (c *ClusterManager) CreateEKSAReleaseBundle(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be done from the eks-a installer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up using this wrapper because while creating the cluster's namespace we use the cluster Client that is a private Retrier Client field used by the cluster manager. I won't be able to use the cluster client if I were to move this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need "the clusterctl client"? we should only need a k8s client wrapped by a retrier
which the installer should already have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I meant the cluster client.
fb0ae0e
to
0145636
Compare
/test eks-anywhere-generate-files-presubmits |
/retest |
pkg/clustermanager/eksa_installer.go
Outdated
// CreateNamespaceIfNotPresent creates the cluster namespace if it doesn not exist. | ||
func (i *EKSAInstaller) CreateNamespaceIfNotPresent(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error { | ||
if spec.Cluster.Namespace != "" { | ||
if err := i.client.CreateNamespaceIfNotPresent(ctx, cluster.KubeconfigFile, spec.Cluster.Namespace); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should not do this
It should be the use the one creating the namespace before calling eks-a if they want to create a cluster in it
|
||
client := clustermanager.NewRetrierClient( | ||
&clusterManagerClient{ | ||
f.dependencies.Clusterctl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need clusterctl for the eksa installer? shouldn't it be enough with a k8s client?
@@ -1103,6 +1104,39 @@ func (f *Factory) WithClusterManager(clusterConfig *v1alpha1.Cluster, timeoutOpt | |||
return f | |||
} | |||
|
|||
// WithEKSAInstaller builds a cluster manager based on the cluster config and timeout options. | |||
func (f *Factory) WithEKSAInstaller(clusterConfig *v1alpha1.Cluster, timeoutOpts *ClusterManagerTimeoutOptions) *Factory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we update the clustermanager build method to make use of this one?
type EksaInstaller interface { | ||
ApplyBundles(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | ||
ApplyReleases(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | ||
CreateNamespaceIfNotPresent(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we should have
type EksaInstaller interface { | |
ApplyBundles(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | |
ApplyReleases(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | |
CreateNamespaceIfNotPresent(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | |
} | |
type EksaInstaller interface { | |
Install(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error | |
} |
if we can't do that for some reason, let's talk about why and try to figure out a solution
) | ||
} | ||
|
||
// func (c *createTestSetup) expectInstallEksaComponentsBootstrap(err1, err2, err3, err4 error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this not needed? if so, let's remove it
} | ||
} | ||
|
||
// func TestCreateEKSAReleaseBundleFailure(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
pkg/clustermanager/eksa_installer.go
Outdated
@@ -108,6 +109,47 @@ func (i *EKSAInstaller) Upgrade(ctx context.Context, log logr.Logger, c *types.C | |||
return changeDiff, nil | |||
} | |||
|
|||
// ApplyBundles applies the bundles to the cluster. | |||
func (i *EKSAInstaller) ApplyBundles(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can all these methods be part of Install
? (you can make them unexported and then call them from Install
)
8e5273a
to
0528213
Compare
0528213
to
b7d3bfc
Compare
@mitalipaygude: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Issue #, if available:
Description of changes:
Create management cluster using controller bootstrap task
The original #7110 is being split into smaller PRs. This PR is the first one.
Testing (if applicable):
Documentation added/planned (if applicable):
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.