@@ -16,6 +16,8 @@ package integration_test
16
16
17
17
import (
18
18
. "github.com/onsi/ginkgo/v2"
19
+ . "github.com/onsi/gomega"
20
+ appsv1 "k8s.io/api/apps/v1"
19
21
v1 "k8s.io/api/core/v1"
20
22
"knative.dev/pkg/ptr"
21
23
@@ -27,15 +29,22 @@ import (
27
29
28
30
var _ = Describe ("KubeletConfiguration Overrides" , func () {
29
31
It ("should schedule pods onto separate nodes when maxPods is set" , func () {
32
+ // Get the total number of daemonsets so that we see how many pods will be taken up
33
+ // by daemonset overhead
34
+ dsList := & appsv1.DaemonSetList {}
35
+ Expect (env .Client .List (env .Context , dsList )).To (Succeed ())
36
+ dsCount := len (dsList .Items )
37
+
30
38
provider := test .AWSNodeTemplate (v1alpha1.AWSNodeTemplateSpec {AWS : awsv1alpha1.AWS {
31
39
SecurityGroupSelector : map [string ]string {"karpenter.sh/discovery" : env .ClusterName },
32
40
SubnetSelector : map [string ]string {"karpenter.sh/discovery" : env .ClusterName },
33
41
}})
42
+
34
43
// MaxPods needs to account for the daemonsets that will run on the nodes
35
44
provisioner := test .Provisioner (test.ProvisionerOptions {
36
45
ProviderRef : & v1alpha5.ProviderRef {Name : provider .Name },
37
46
Kubelet : & v1alpha5.KubeletConfiguration {
38
- MaxPods : ptr .Int32 (3 ),
47
+ MaxPods : ptr .Int32 (1 + int32 ( dsCount ) ),
39
48
},
40
49
})
41
50
@@ -48,6 +57,12 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
48
57
env .ExpectCreatedNodeCount ("==" , 3 )
49
58
})
50
59
It ("should schedule pods onto separate nodes when podsPerCore is set" , func () {
60
+ // Get the total number of daemonsets so that we see how many pods will be taken up
61
+ // by daemonset overhead
62
+ dsList := & appsv1.DaemonSetList {}
63
+ Expect (env .Client .List (env .Context , dsList )).To (Succeed ())
64
+ dsCount := len (dsList .Items )
65
+
51
66
provider := test .AWSNodeTemplate (v1alpha1.AWSNodeTemplateSpec {AWS : awsv1alpha1.AWS {
52
67
SecurityGroupSelector : map [string ]string {"karpenter.sh/discovery" : env .ClusterName },
53
68
SubnetSelector : map [string ]string {"karpenter.sh/discovery" : env .ClusterName },
@@ -57,13 +72,13 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
57
72
provisioner := test .Provisioner (test.ProvisionerOptions {
58
73
ProviderRef : & v1alpha5.ProviderRef {Name : provider .Name },
59
74
Kubelet : & v1alpha5.KubeletConfiguration {
60
- PodsPerCore : ptr .Int32 (2 ),
75
+ PodsPerCore : ptr .Int32 (2 + int32 ( dsCount ) ),
61
76
},
62
77
Requirements : []v1.NodeSelectorRequirement {
63
78
{
64
79
Key : awsv1alpha1 .LabelInstanceCPU ,
65
80
Operator : v1 .NodeSelectorOpIn ,
66
- Values : []string {"2 " },
81
+ Values : []string {"1 " },
67
82
},
68
83
},
69
84
})
@@ -87,13 +102,13 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
87
102
provisioner := test .Provisioner (test.ProvisionerOptions {
88
103
ProviderRef : & v1alpha5.ProviderRef {Name : provider .Name },
89
104
Kubelet : & v1alpha5.KubeletConfiguration {
90
- PodsPerCore : ptr .Int32 (2 ),
105
+ PodsPerCore : ptr .Int32 (1 ),
91
106
},
92
107
Requirements : []v1.NodeSelectorRequirement {
93
108
{
94
109
Key : awsv1alpha1 .LabelInstanceCPU ,
95
110
Operator : v1 .NodeSelectorOpIn ,
96
- Values : []string {"2 " },
111
+ Values : []string {"1 " },
97
112
},
98
113
},
99
114
})
@@ -104,6 +119,6 @@ var _ = Describe("KubeletConfiguration Overrides", func() {
104
119
env .ExpectCreated (pod )
105
120
}
106
121
env .EventuallyExpectHealthy (pods ... )
107
- env .ExpectCreatedNodeCount ("<= " , 2 ) // should probably all land on a single node, but at worst two depending on batching
122
+ env .ExpectCreatedNodeCount ("== " , 1 )
108
123
})
109
124
})
0 commit comments