Skip to content

Commit

Permalink
fix: properly quote Bottlerocket config
Browse files Browse the repository at this point in the history
In TOML, bare keys have limitations in the keys that they can contain
([A-Za-z0-9_-]) and strings _must_ be quoted. This change quotes all
keys to properly handle e.g. node labels with slashes in them and also
adds missing quotes for node taint values.
  • Loading branch information
DWSR committed Feb 23, 2022
1 parent caff8aa commit aabe61c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/cloudprovider/aws/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,12 @@ func (p *LaunchTemplateProvider) getUserData(ctx context.Context, constraints *v
}

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)
userData := fmt.Sprintf("[settings.kubernetes]\n\"cluster-name\" = \"%s\"\n\"api-server\" = \"%s\"\n", injection.GetOptions(ctx).ClusterName, injection.GetOptions(ctx).ClusterEndpoint)
if len(constraints.KubeletConfiguration.ClusterDNS) > 0 {
userData += fmt.Sprintf("cluster-dns-ip = \"%s\"\n", constraints.KubeletConfiguration.ClusterDNS[0])
userData += fmt.Sprintf("\"cluster-dns-ip\" = \"%s\"\n", constraints.KubeletConfiguration.ClusterDNS[0])
}
if caBundle != nil {
userData += fmt.Sprintf("cluster-certificate = \"%s\"\n", *caBundle)
userData += fmt.Sprintf("\"cluster-certificate\" = \"%s\"\n", *caBundle)
}
nodeLabelArgs := functional.UnionStringMaps(additionalLabels, constraints.Labels)
if len(nodeLabelArgs) > 0 {
Expand All @@ -305,7 +305,7 @@ func (p *LaunchTemplateProvider) getBottlerocketUserData(ctx context.Context, co
userData += "[settings.kubernetes.node-taints]\n"
sorted := sortedTaints(constraints.Taints)
for _, taint := range sorted {
userData += fmt.Sprintf("%s=%s:%s\n", taint.Key, taint.Value, taint.Effect)
userData += fmt.Sprintf("\"%s\"=\"%s:%s\"\n", taint.Key, taint.Value, taint.Effect)
}
}
return base64.StdEncoding.EncodeToString([]byte(userData))
Expand Down

0 comments on commit aabe61c

Please sign in to comment.