Skip to content

Commit

Permalink
pr updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bwagner5 committed Feb 9, 2022
1 parent f1cb013 commit 4c70160
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/cloudprovider/aws/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,9 @@ func (p *LaunchTemplateProvider) Get(ctx context.Context, constraints *v1alpha1.
return nil, fmt.Errorf("getting ca bundle for user data, %w", err)
}
for amiID, instanceTypes := range amis {
userData := p.getEKSOptimizedUserData(ctx, constraints, instanceTypes, additionalLabels, caBundle)
if aws.StringValue(constraints.AMIFamily) == v1alpha1.AMIFamilyBottlerocket {
userData = p.getBottlerocketUserData(ctx, constraints, additionalLabels, caBundle)
}
if err != nil {
return nil, err
}
// Ensure the launch template exists, or create it
launchTemplate, err := p.ensureLaunchTemplate(ctx, &launchTemplateOptions{
UserData: userData,
UserData: p.getUserData(ctx, constraints, instanceTypes, additionalLabels, caBundle),
ClusterName: injection.GetOptions(ctx).ClusterName,
InstanceProfile: instanceProfile,
AMIID: amiID,
Expand Down Expand Up @@ -246,6 +239,13 @@ func sortedKeys(m map[string]string) []string {
return keys
}

func (p *LaunchTemplateProvider) getUserData(ctx context.Context, constraints *v1alpha1.Constraints, instanceTypes []cloudprovider.InstanceType, additionalLabels map[string]string, caBundle *string) string {
if aws.StringValue(constraints.AMIFamily) == v1alpha1.AMIFamilyBottlerocket {
return p.getBottlerocketUserData(ctx, constraints, additionalLabels, caBundle)
}
return p.getEKSOptimizedUserData(ctx, constraints, instanceTypes, additionalLabels, caBundle)
}

func (p *LaunchTemplateProvider) getBottlerocketUserData(ctx context.Context, constraints *v1alpha1.Constraints, additionalLabels map[string]string, caBundle *string) string {
userData := fmt.Sprintf("[settings.kubernetes]\ncluster-name = \"%s\"\napi-server = \"%s\"\n", injection.GetOptions(ctx).ClusterName, injection.GetOptions(ctx).ClusterEndpoint)
if constraints.KubeletConfiguration.ClusterDNS != nil {
Expand Down

0 comments on commit 4c70160

Please sign in to comment.