Skip to content

✨ Support storing Ignition user data in S3 bucket for AWSMachinePool #5318

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

AndiDog
Copy link
Contributor

@AndiDog AndiDog commented Jan 22, 2025

What this PR does / why we need it:

Reopened from #5172 because of branch issues.

EC2 user data is insecure and very limited in size (16 KB). Use the S3 bucket storage also for machine pools. The difference to AWSMachine is that the S3 objects must stay around because a new instance could be started by the ASG at any time, and user data with a valid token must exist. Both a lifecycle policy for regular deletion, and explicit S3 object deletion requests, are used for cleanup, so that normally, only 1-3 launch template versions' user data are stored in S3. Each launch template version relates to one S3 object.

What type of PR is this?

/kind feature

Which issue(s) this PR fixes:

Didn't find an existing issue. My company ran into EC2 user data size limit problems.

Special notes for your reviewer:

This change has been successfully used in the Giant Swarm fork of CAPA since July 2024, on production clusters. I have adapted the change to the latest upstream changes, in particular the introduction of IgnitionStorageTypeOption (#4700) and made sure the previous default storage type is kept. Therefore, I retested this feature using Tilt on a plain CAPI@main + CAPA@main setup, with AWSCluster + Flatcar AMI + AWSMachinePool in my manifests.

Checklist:

  • squashed commits
  • includes documentation
  • includes emojis
  • adds unit tests
  • adds or updates e2e tests

Release note:

action required
Support storing Ignition user data in S3 bucket for `AWSMachinePool`. If you plan to use this feature then you will need to update the permissions for CAPA using clusterawsadm. 

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 22, 2025
@k8s-ci-robot k8s-ci-robot added needs-priority size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 22, 2025
@AndiDog
Copy link
Contributor Author

AndiDog commented Jan 24, 2025

/test pull-cluster-api-provider-aws-test

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 24, 2025
@AndiDog AndiDog force-pushed the s3-user-data branch 2 times, most recently from 0972f68 to 4a31f81 Compare January 24, 2025 08:59
@AndiDog
Copy link
Contributor Author

AndiDog commented Jan 24, 2025

/test pull-cluster-api-provider-aws-e2e

1 similar comment
@AndiDog
Copy link
Contributor Author

AndiDog commented Jan 27, 2025

/test pull-cluster-api-provider-aws-e2e

@@ -280,7 +296,7 @@ func (r *AWSMachinePoolReconciler) reconcileNormal(ctx context.Context, machineP
machinePoolScope.Info("starting instance refresh", "number of instances", machinePoolScope.MachinePool.Spec.Replicas)
return asgsvc.StartASGInstanceRefresh(machinePoolScope)
}
if err := reconSvc.ReconcileLaunchTemplate(machinePoolScope, ec2Svc, canUpdateLaunchTemplate, runPostLaunchTemplateUpdateOperation); err != nil {
if err := reconSvc.ReconcileLaunchTemplate(machinePoolScope, machinePoolScope, s3Scope, ec2Svc, objectStoreSvc, canUpdateLaunchTemplate, runPostLaunchTemplateUpdateOperation); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to pass the same machinePoolScope twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets cast to two different interfaces (IgnitionScope and LaunchTemplateScope). The number of small interfaces is to blame here, but many of them are needed to easily mock functionality or share functionality between regular and EKS cluster code and types.

@@ -607,7 +623,7 @@ func machinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind) handler.Map
}
}

func (r *AWSMachinePoolReconciler) getInfraCluster(ctx context.Context, log *logger.Logger, cluster *clusterv1.Cluster, awsMachinePool *expinfrav1.AWSMachinePool) (scope.EC2Scope, error) {
func (r *AWSMachinePoolReconciler) getInfraCluster(ctx context.Context, log *logger.Logger, cluster *clusterv1.Cluster, awsMachinePool *expinfrav1.AWSMachinePool) (scope.EC2Scope, scope.S3Scope, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is no case where the first and second returned values are different. They are always both the same value, either nil or clusterScope or managedControlplaneScope. If both always have the same value, couldn't we just return one instead of two values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment regarding interfaces

Copy link
Contributor

@fiunchinho fiunchinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 28, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 14, 2025
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 25, 2025
@AndiDog
Copy link
Contributor Author

AndiDog commented Mar 25, 2025

/test pull-cluster-api-provider-aws-e2e

@fiunchinho
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 27, 2025
@richardcase
Copy link
Member

/test pull-cluster-api-provider-aws-e2e-eks

@AndiDog
Copy link
Contributor Author

AndiDog commented May 15, 2025

/retest

@AndiDog
Copy link
Contributor Author

AndiDog commented May 15, 2025

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@fiunchinho
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7e4549c5a34ebafdffd2931285f452593d5dd11d

@k8s-ci-robot k8s-ci-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 28, 2025
@richardcase
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: richardcase

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 28, 2025
@fiunchinho
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 4, 2025
@AndiDog
Copy link
Contributor Author

AndiDog commented Jun 4, 2025

I've manually re-tested this after the major migration to AWS SDK for Go v2.

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@damdo
Copy link
Member

damdo commented Jun 4, 2025

@fiunchinho can you re-add your LGTM here?

@damdo
Copy link
Member

damdo commented Jun 4, 2025

/test pull-cluster-api-provider-aws-e2e pull-cluster-api-provider-aws-e2e-eks

@AndiDog
Copy link
Contributor Author

AndiDog commented Jun 10, 2025

E2E test should hopefully now be fixed (problem in AWS SDK Go v2 change), trying again

/test pull-cluster-api-provider-aws-e2e

@k8s-ci-robot
Copy link
Contributor

@AndiDog: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-aws-e2e 460da84 link false /test pull-cluster-api-provider-aws-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

@AndiDog
Copy link
Contributor Author

AndiDog commented Jun 11, 2025

/test pull-cluster-api-provider-aws-e2e

@fiunchinho
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 5877d0d7353d151f7da4cf50158f58b43e448858

@k8s-ci-robot k8s-ci-robot merged commit e7dddb6 into kubernetes-sigs:main Jun 11, 2025
16 of 17 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v2.8 milestone Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants