Skip to content

Commit

Permalink
Get rid of the equal char when calling bootstrap.sh (#1520)
Browse files Browse the repository at this point in the history
* Get rid of the equal sign because the bootstrap.sh will not properly parse it and assume its empty. Which will result in it trying to find the API server automatically which works for EKS cluster but does not for others

* remove more equals

* use-max-pods had = before so add it back

* remove equal for use max pods as well

* add comment to clarify why we can't have equal signs here

* change tests to comply with lack of equals
  • Loading branch information
spring1843 authored Mar 15, 2022
1 parent afc6759 commit f62cf98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions pkg/cloudprovider/aws/amifamily/bootstrap/eksbootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,25 @@ type EKS struct {
func (e EKS) Script() string {
var caBundleArg string
if e.CABundle != nil {
caBundleArg = fmt.Sprintf("--b64-cluster-ca='%s'", *e.CABundle)
caBundleArg = fmt.Sprintf("--b64-cluster-ca '%s'", *e.CABundle)
}
var userData bytes.Buffer
userData.WriteString("#!/bin/bash -xe\n")
userData.WriteString("exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1\n")
userData.WriteString(fmt.Sprintf("/etc/eks/bootstrap.sh '%s' --apiserver-endpoint='%s' %s", e.ClusterName, e.ClusterEndpoint, caBundleArg))
// Due to the way bootstrap.sh is written, parameters should not be passed to it with an equal sign
userData.WriteString(fmt.Sprintf("/etc/eks/bootstrap.sh '%s' --apiserver-endpoint '%s' %s", e.ClusterName, e.ClusterEndpoint, caBundleArg))

kubeletExtraArgs := strings.Join([]string{e.nodeLabelArg(), e.nodeTaintArg()}, " ")

if !e.AWSENILimitedPodDensity {
userData.WriteString(" \\\n--use-max-pods=false")
userData.WriteString(" \\\n--use-max-pods false")
kubeletExtraArgs += " --max-pods=110"
}
if kubeletExtraArgs = strings.Trim(kubeletExtraArgs, " "); len(kubeletExtraArgs) > 0 {
userData.WriteString(fmt.Sprintf(" \\\n--kubelet-extra-args='%s'", kubeletExtraArgs))
userData.WriteString(fmt.Sprintf(" \\\n--kubelet-extra-args '%s'", kubeletExtraArgs))
}
if e.KubeletConfig != nil && len(e.KubeletConfig.ClusterDNS) > 0 {
userData.WriteString(fmt.Sprintf(" \\\n--dns-cluster-ip='%s'", e.KubeletConfig.ClusterDNS[0]))
userData.WriteString(fmt.Sprintf(" \\\n--dns-cluster-ip '%s'", e.KubeletConfig.ClusterDNS[0]))
}
return base64.StdEncoding.EncodeToString(userData.Bytes())
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cloudprovider/aws/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ var _ = Describe("Allocation", func() {
Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1))
input := fakeEC2API.CalledWithCreateLaunchTemplateInput.Pop().(*ec2.CreateLaunchTemplateInput)
userData, _ := base64.StdEncoding.DecodeString(*input.LaunchTemplateData.UserData)
Expect(string(userData)).NotTo(ContainSubstring("--use-max-pods=false"))
Expect(string(userData)).NotTo(ContainSubstring("--use-max-pods false"))
})
It("should specify --use-max-pods=false when not using ENI-based pod density", func() {
opts.AWSENILimitedPodDensity = false
Expand All @@ -640,7 +640,7 @@ var _ = Describe("Allocation", func() {
Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1))
input := fakeEC2API.CalledWithCreateLaunchTemplateInput.Pop().(*ec2.CreateLaunchTemplateInput)
userData, _ := base64.StdEncoding.DecodeString(*input.LaunchTemplateData.UserData)
Expect(string(userData)).To(ContainSubstring("--use-max-pods=false"))
Expect(string(userData)).To(ContainSubstring("--use-max-pods false"))
Expect(string(userData)).To(ContainSubstring("--max-pods=110"))
})
Context("Kubelet Args", func() {
Expand All @@ -651,7 +651,7 @@ var _ = Describe("Allocation", func() {
Expect(fakeEC2API.CalledWithCreateLaunchTemplateInput.Cardinality()).To(Equal(1))
input := fakeEC2API.CalledWithCreateLaunchTemplateInput.Pop().(*ec2.CreateLaunchTemplateInput)
userData, _ := base64.StdEncoding.DecodeString(*input.LaunchTemplateData.UserData)
Expect(string(userData)).To(ContainSubstring("--dns-cluster-ip='10.0.10.100'"))
Expect(string(userData)).To(ContainSubstring("--dns-cluster-ip '10.0.10.100'"))
})
})
Context("Instance Profile", func() {
Expand Down

0 comments on commit f62cf98

Please sign in to comment.