@@ -15,6 +15,7 @@ limitations under the License.
15
15
package scheduling_test
16
16
17
17
import (
18
+ "encoding/json"
18
19
"fmt"
19
20
"testing"
20
21
"time"
@@ -26,6 +27,7 @@ import (
26
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
28
"k8s.io/apimachinery/pkg/labels"
28
29
"k8s.io/apimachinery/pkg/util/sets"
30
+ "sigs.k8s.io/karpenter/pkg/apis/v1beta1"
29
31
30
32
karpv1 "sigs.k8s.io/karpenter/pkg/apis/v1"
31
33
"sigs.k8s.io/karpenter/pkg/test"
@@ -99,6 +101,28 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
99
101
env .ExpectCreatedNodeCount ("==" , 1 )
100
102
Expect (env .GetNode (pod .Spec .NodeName ).Annotations ).To (And (HaveKeyWithValue ("foo" , "bar" ), HaveKeyWithValue (karpv1 .DoNotDisruptAnnotationKey , "true" )))
101
103
})
104
+ It ("should ensure the NodePool and the NodeClaim use the same view of the v1beta1 kubelet configuration" , func () {
105
+ v1beta1NodePool := & v1beta1.NodePool {}
106
+ Expect (nodePool .ConvertTo (env .Context , v1beta1NodePool )).To (Succeed ())
107
+
108
+ // Allow a reasonable number of pods to schedule
109
+ v1beta1NodePool .Spec .Template .Spec .Kubelet = & v1beta1.KubeletConfiguration {
110
+ PodsPerCore : lo .ToPtr (int32 (2 )),
111
+ }
112
+ kubeletHash , err := json .Marshal (v1beta1NodePool .Spec .Template .Spec .Kubelet )
113
+ Expect (err ).ToNot (HaveOccurred ())
114
+ // Ensure that the v1 version of the NodeClass has a configuration that won't let pods schedule
115
+ nodeClass .Spec .Kubelet = & v1.KubeletConfiguration {
116
+ MaxPods : lo .ToPtr (int32 (0 )),
117
+ }
118
+ pod := test .Pod ()
119
+ env .ExpectCreated (nodeClass , v1beta1NodePool , pod )
120
+
121
+ nodeClaim := env .EventuallyExpectCreatedNodeClaimCount ("==" , 1 )[0 ]
122
+ Expect (nodeClaim .Annotations ).To (HaveKeyWithValue (karpv1 .KubeletCompatibilityAnnotationKey , string (kubeletHash )))
123
+ env .EventuallyExpectCreatedNodeCount ("==" , 1 )
124
+ env .EventuallyExpectHealthy (pod )
125
+ })
102
126
103
127
Context ("Labels" , func () {
104
128
It ("should support well-known labels for instance type selection" , func () {
@@ -487,7 +511,6 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
487
511
Expect (lo .FromPtr (env .GetInstance (pod .Spec .NodeName ).InstanceType )).To (Equal ("c5.large" ))
488
512
Expect (env .GetNode (pod .Spec .NodeName ).Labels [karpv1 .NodePoolLabelKey ]).To (Equal (nodePoolHighPri .Name ))
489
513
})
490
-
491
514
DescribeTable (
492
515
"should provision a right-sized node when a pod has InitContainers (cpu)" ,
493
516
func (expectedNodeCPU string , containerRequirements corev1.ResourceRequirements , initContainers ... corev1.Container ) {
@@ -624,7 +647,6 @@ var _ = Describe("Scheduling", Ordered, ContinueOnFailure, func() {
624
647
env .ExpectCreated (nodePool , nodeClass , pod )
625
648
env .EventuallyExpectHealthy (pod )
626
649
})
627
-
628
650
It ("should provision a node for a pod with overlapping zone and zone-id requirements" , func () {
629
651
subnetInfo := lo .UniqBy (env .GetSubnetInfo (map [string ]string {"karpenter.sh/discovery" : env .ClusterName }), func (s environmentaws.SubnetInfo ) string {
630
652
return s .Zone
0 commit comments