Skip to content

Commit 8cda93d

Browse files
authored
fix: don't set max pods above kubernetes recommended limit (#342)
* fix: don't set max pods above kubernetes recommended limit Signed-off-by: Jonah Back <[email protected]> * move min to common Signed-off-by: Jonah Back <[email protected]> * remove whitespace Signed-off-by: Jonah Back <[email protected]>
1 parent 306c823 commit 8cda93d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

controllers/common/utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ func StringSliceContains(x, y []string) bool {
256256
return true
257257
}
258258

259+
func Min(a, b int64) int64 {
260+
if a < b {
261+
return a
262+
}
263+
return b
264+
}
265+
259266
func GetLastElementBy(s, sep string) string {
260267
sp := strings.Split(s, sep)
261268
return sp[len(sp)-1]

controllers/provisioners/eks/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ func (ctx *EksInstanceGroupContext) GetComputedBootstrapOptions() *v1alpha1.Boot
511511
ipsPerInterface = 16 //Number of ips in a /28 block
512512
}
513513

514-
maxPods = enis*((aws.Int64Value(instanceTypeNetworkInfo.Ipv4AddressesPerInterface)-1)*ipsPerInterface) + hostNetworkPods
514+
// Don't set maxPods above Kubernetes-recommended 110 per node for large clusters.
515+
maxPods = common.Min(enis*((aws.Int64Value(instanceTypeNetworkInfo.Ipv4AddressesPerInterface)-1)*ipsPerInterface) + hostNetworkPods, 110)
515516

516517
if configuration.BootstrapOptions == nil {
517518
return &v1alpha1.BootstrapOptions{

controllers/provisioners/eks/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func TestCustomNetworkingMaxPods(t *testing.T) {
403403
CustomNetworkingEnabledAnnotation: "true",
404404
},
405405
bootstrapOptions: nil,
406-
expectedMaxPods: "--max-pods=290",
406+
expectedMaxPods: "--max-pods=110",
407407
},
408408
{
409409
annotations: map[string]string{

0 commit comments

Comments
 (0)