-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(eks): add eks cluster builder #1259
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jay Chen <1180092+jijiechen@users.noreply.github.com>
TagNameCreateBy = "ktf_created_by" | ||
) | ||
|
||
func CreateEKSClusterAll(ctx context.Context, cfg aws.Config, clusterName, |
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.
It looks like to be a function to create a cluster and all its dependencies. Could we add comments to tell this?
) | ||
|
||
func CreateEKSClusterAll(ctx context.Context, cfg aws.Config, clusterName, | ||
k8sMinorVersion, nodeMachineType string, tags map[string]string) 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.
Could we group the parameters with the same type to the same line to make a clearer view on the types of the params?
return errors.Wrapf(err, "failed to get availability zones in region %s", cfg.Region) | ||
} | ||
|
||
vpcId, subnetIDs, err := createVPC(ctx, ec2Client, subnetAvZones) |
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.
Could it leave dangling resources when error happens after creating a VPC? I think we need to clean them if possible, or add a comment to tell that it may leave resource to clear.
return nil | ||
} | ||
|
||
func DeleteEKSClusterAll(ctx context.Context, cfg aws.Config, clusterName string) 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.
Ditto here. I think we need to add comments to tell what resources are deleted here.
func waitForClusterActive(ctx context.Context, eksClient *eks.Client, clusterName string) (*types.Cluster, error) { | ||
childCtx, cancel := context.WithTimeout(ctx, 10*time.Minute) | ||
defer cancel() | ||
ticker := time.NewTicker(10 * time.Second) |
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 the 10 second ticker too long? Or should we make the wait time and wait tick configurable?
} | ||
|
||
func waitForNodeGroupReady(ctx context.Context, eksClient *eks.Client, clusterName, nodeGroupName string) error { | ||
childCtx, cancel := context.WithTimeout(ctx, 10*time.Minute) |
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.
Ditto here for wait time and wait tick.
closes #285
Features
This PR provides the following features:
Builder
for creating EKS clusters on AWSCluster
representing the cluster created and provides the functionality of cleaning up the cluster and all underlying resources createdNewFromExisting
helper function to retrieve kubeconfig from an existing clusterAbove features are tested manually and a CI run can be found here:
https://github.com/kumahq/kuma-smoke/actions/runs/12785877388/job/35641958835
Implementation
Unlike
eksctl
which creates the cluster using AWS CloudFormation, this PR creates underlying AWS resources directly using the Golang SDK provided by AWS.The entrypoint for creating a new cluster is the function
eks.aws_operations.CreateEKSClusterAll
The entrypoint for cleaning up a cluster is the function
eks.aws_operations.DeleteEKSClusterAll
Reused the logic of
eksctl
to generateuserdata
for bootstraping the nodes.Limitations
Usage
I'll provide an integration test soon in a new PR.