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

Support user-supplied bootstrap configuration #66

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

eaudetcobello
Copy link
Contributor

Implements first-party support for supplying a bootstrap configuration (before this, it was done by overriding install.sh and adding a file under extraFiles).

The BootstrapConfig type re-uses the existing FileSource type so that a secret reference can be used to seed the configuration just like we have for files, (e.g. contentFrom).

Comment on lines -436 to +534
func (r *CK8sConfigReconciler) resolveSecretFileContent(ctx context.Context, ns string, source bootstrapv1.File) ([]byte, error) {
func (r *CK8sConfigReconciler) resolveSecretFileContent(ctx context.Context, ns string, source bootstrapv1.FileSource) ([]byte, error) {
Copy link
Contributor Author

@eaudetcobello eaudetcobello Oct 8, 2024

Choose a reason for hiding this comment

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

I changed the parameter type from File to FileSource because 1. We do not use any of the fields from the File type, except ContentFrom. 2. This makes the function reusable for any other types that have a FileSource (and therefore reference a secret), but are not an explicit abstraction of a File.

Comment on lines +593 to +670
userSuppliedBootstrapConfig, err := r.resolveUserBootstrapConfig(ctx, scope.Config)
if err != nil {
conditions.MarkFalse(scope.Config, bootstrapv1.DataSecretAvailableCondition, bootstrapv1.DataSecretGenerationFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
return ctrl.Result{}, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolveUserBootstrapConfig returns an empty string if there is no user-supplied configuration, we check this later in common.go.

Comment on lines 84 to 103
var configFileContents string
switch {
case data.BootstrapConfig != "":
// User-supplied bootstrap configuration from CK8sConfig object.
configFileContents = data.BootstrapConfig
default:
configFileContents = data.ConfigFileContents
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

user-supplied bootstrap configuration has precedence over our ConfigFileContents

Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

Looks good, added some comments

bootstrap/controllers/ck8sconfig_controller.go Outdated Show resolved Hide resolved
pkg/cloudinit/common.go Outdated Show resolved Hide resolved
pkg/cloudinit/controlplane_init_test.go Show resolved Hide resolved
templates/aws/cluster-template.yaml Outdated Show resolved Hide resolved
pkg/cloudinit/common.go Outdated Show resolved Hide resolved
@eaudetcobello eaudetcobello force-pushed the KU-1612/user-supplied-bootstrap-config branch from 851c053 to 102cf8e Compare October 15, 2024 15:56
@eaudetcobello eaudetcobello force-pushed the KU-1612/user-supplied-bootstrap-config branch from e3c9386 to bffa5e4 Compare October 15, 2024 18:10
@eaudetcobello eaudetcobello marked this pull request as ready for review October 15, 2024 18:12
@eaudetcobello eaudetcobello requested a review from a team as a code owner October 15, 2024 18:12
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

LGTM

@eaudetcobello eaudetcobello merged commit ec74311 into main Oct 15, 2024
8 checks passed
@eaudetcobello eaudetcobello deleted the KU-1612/user-supplied-bootstrap-config branch October 15, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants