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

chore: add bottlerocket support for kubeletconfiguration evictionsoft #6760

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions pkg/providers/amifamily/bootstrap/bottlerocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func (b Bottlerocket) Script() (string, error) {
if b.KubeletConfig.EvictionHard != nil {
anandg112 marked this conversation as resolved.
Show resolved Hide resolved
s.Settings.Kubernetes.EvictionHard = b.KubeletConfig.EvictionHard
}
if b.KubeletConfig.EvictionSoft != nil {
s.Settings.Kubernetes.EvictionSoft = b.KubeletConfig.EvictionSoft
}
if b.KubeletConfig.ImageGCHighThresholdPercent != nil {
s.Settings.Kubernetes.ImageGCHighThresholdPercent = lo.ToPtr(strconv.FormatInt(int64(*b.KubeletConfig.ImageGCHighThresholdPercent), 10))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type BottlerocketKubernetes struct {
MaxPods *int `toml:"max-pods,omitempty"`
StaticPods map[string]BottlerocketStaticPod `toml:"static-pods,omitempty"`
EvictionHard map[string]string `toml:"eviction-hard,omitempty"`
EvictionSoft map[string]string `toml:"eviction-soft,omitempty"`
KubeReserved map[string]string `toml:"kube-reserved,omitempty"`
SystemReserved map[string]string `toml:"system-reserved,omitempty"`
AllowedUnsafeSysctls []string `toml:"allowed-unsafe-sysctls,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion pkg/providers/amifamily/bottlerocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (b Bottlerocket) FeatureFlags() FeatureFlags {
return FeatureFlags{
UsesENILimitedMemoryOverhead: false,
PodsPerCoreEnabled: false,
EvictionSoftEnabled: false,
SupportsENILimitedPodDensity: true,
}
}
1 change: 1 addition & 0 deletions test/suites/ami/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ var _ = Describe("AMI", func() {
actualUserData, err := base64.StdEncoding.DecodeString(*getInstanceAttribute(pod.Spec.NodeName, "userData").UserData.Value)
Expect(err).ToNot(HaveOccurred())
Expect(string(actualUserData)).To(ContainSubstring("kube-api-qps = 30"))
Expect(string(actualUserData)).To(ContainSubstring("memory.available = 300Mi"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we validate that we this value is assigned to the eviction soft section? As it stands, this check would pass if we passed the same key to eviction hard

Copy link
Author

Choose a reason for hiding this comment

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

Added the E2E integration test as requested, please review at your convenience, thx!

})
// Windows tests are can flake due to the instance types that are used in testing.
// The VPC Resource controller will need to support the instance types that are used.
Expand Down
2 changes: 2 additions & 0 deletions test/suites/ami/testdata/br_userdata_input.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
kube-api-qps = 30
[settings.kubernetes.node-taints]
"node.cilium.io/agent-not-ready" = ["true:NoExecute"]
[settings.kubernetes.eviction-soft]
"memory.available" = "300Mi"
22 changes: 22 additions & 0 deletions test/suites/integration/kubelet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,28 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
})
selector := labels.SelectorFromSet(dep.Spec.Selector.MatchLabels)

env.ExpectCreated(nodeClass, nodePool, dep)
env.EventuallyExpectHealthyPodCount(selector, numPods)
env.ExpectCreatedNodeCount("==", 1)
env.EventuallyExpectUniqueNodeNames(selector, 1)
})
It("should use evictionSoft and evictionHard settings in kubelet when Bottlerocket is used", func() {
nodeClass.Spec.AMISelectorTerms = []v1.AMISelectorTerm{{Alias: "bottlerocket@latest"}}
nodeClass.Spec.Kubelet = &v1.KubeletConfiguration{
EvictionSoft: map[string]string{"memory.available": "10%"},
EvictionHard: map[string]string{"memory.available": "5%"},
}
numPods := 3
dep := test.Deployment(test.DeploymentOptions{
Replicas: int32(numPods),
PodOptions: test.PodOptions{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"app": "sample-app"},
},
},
})
selector := labels.SelectorFromSet(dep.Spec.Selector.MatchLabels)

env.ExpectCreated(nodeClass, nodePool, dep)
env.EventuallyExpectHealthyPodCount(selector, numPods)
env.ExpectCreatedNodeCount("==", 1)
Expand Down