@@ -44,12 +44,8 @@ const (
44
44
KarpenterNodePoolReadyCondition capi.ConditionType = "KarpenterNodePoolReadyCondition"
45
45
// WaitingForBootstrapDataReason used when machine is waiting for bootstrap data to be ready before proceeding.
46
46
WaitingForBootstrapDataReason = "WaitingForBootstrapData"
47
- // NodePoolCreatedReason indicates that the NodePool was successfully created
48
- NodePoolCreatedReason = "NodePoolCreated"
49
47
// NodePoolCreationFailedReason indicates that the NodePool creation failed
50
48
NodePoolCreationFailedReason = "NodePoolCreationFailed"
51
- // EC2NodeClassCreatedReason indicates that the EC2NodeClass was successfully created
52
- EC2NodeClassCreatedReason = "EC2NodeClassCreated"
53
49
// EC2NodeClassCreationFailedReason indicates that the EC2NodeClass creation failed
54
50
EC2NodeClassCreationFailedReason = "EC2NodeClassCreationFailed"
55
51
// VersionSkewBlockedReason indicates that the update was blocked due to version skew policy
@@ -155,6 +151,12 @@ func (r *KarpenterMachinePoolReconciler) Reconcile(ctx context.Context, req reco
155
151
}
156
152
}
157
153
154
+ // Create or update Karpenter resources in the workload cluster
155
+ if err := r .createOrUpdateKarpenterResources (ctx , logger , cluster , awsCluster , karpenterMachinePool , machinePool , bootstrapSecretValue ); err != nil {
156
+ logger .Error (err , "failed to create or update Karpenter resources" )
157
+ return reconcile.Result {}, err
158
+ }
159
+
158
160
bootstrapUserDataHash := fmt .Sprintf ("%x" , sha256 .Sum256 (bootstrapSecretValue ))
159
161
previousHash , annotationHashExists := karpenterMachinePool .Annotations [BootstrapDataHashAnnotation ]
160
162
if ! annotationHashExists || previousHash != bootstrapUserDataHash {
@@ -181,12 +183,6 @@ func (r *KarpenterMachinePoolReconciler) Reconcile(ctx context.Context, req reco
181
183
}
182
184
}
183
185
184
- // Create or update Karpenter resources in the workload cluster
185
- if err := r .createOrUpdateKarpenterResources (ctx , logger , cluster , awsCluster , karpenterMachinePool , machinePool , bootstrapSecretValue ); err != nil {
186
- logger .Error (err , "failed to create or update Karpenter resources" )
187
- return reconcile.Result {}, err
188
- }
189
-
190
186
providerIDList , numberOfNodeClaims , err := r .computeProviderIDListFromNodeClaimsInWorkloadCluster (ctx , logger , cluster )
191
187
if err != nil {
192
188
return reconcile.Result {}, err
@@ -407,7 +403,7 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateKarpenterResources(ctx co
407
403
func (r * KarpenterMachinePoolReconciler ) createOrUpdateEC2NodeClass (ctx context.Context , logger logr.Logger , workloadClusterClient client.Client , cluster * capi.Cluster , awsCluster * capa.AWSCluster , karpenterMachinePool * v1alpha1.KarpenterMachinePool , bootstrapSecretValue []byte ) error {
408
404
ec2NodeClassGVR := schema.GroupVersionResource {
409
405
Group : "karpenter.k8s.aws" ,
410
- Version : "v1beta1 " ,
406
+ Version : "v1 " ,
411
407
Resource : "ec2nodeclasses" ,
412
408
}
413
409
@@ -485,7 +481,7 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateEC2NodeClass(ctx context.
485
481
func (r * KarpenterMachinePoolReconciler ) createOrUpdateNodePool (ctx context.Context , logger logr.Logger , workloadClusterClient client.Client , karpenterMachinePool * v1alpha1.KarpenterMachinePool ) error {
486
482
nodePoolGVR := schema.GroupVersionResource {
487
483
Group : "karpenter.sh" ,
488
- Version : "v1beta1 " ,
484
+ Version : "v1 " ,
489
485
Resource : "nodepools" ,
490
486
}
491
487
@@ -503,10 +499,12 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
503
499
"template" : map [string ]interface {}{
504
500
"spec" : map [string ]interface {}{
505
501
"nodeClassRef" : map [string ]interface {}{
506
- "apiVersion" : "karpenter.k8s.aws/v1beta1" ,
502
+ "apiVersion" : "karpenter.k8s.aws/v1" ,
503
+ "group" : "karpenter.k8s.aws" ,
507
504
"kind" : "EC2NodeClass" ,
508
505
"name" : karpenterMachinePool .Name ,
509
506
},
507
+ "requirements" : []interface {}{},
510
508
},
511
509
},
512
510
}
@@ -547,7 +545,8 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
547
545
}
548
546
requirements = append (requirements , requirement )
549
547
}
550
- spec ["requirements" ] = requirements
548
+
549
+ spec ["template" ].(map [string ]interface {})["spec" ].(map [string ]interface {})["requirements" ] = requirements
551
550
}
552
551
553
552
if len (karpenterMachinePool .Spec .NodePool .Taints ) > 0 {
@@ -602,7 +601,7 @@ func (r *KarpenterMachinePoolReconciler) deleteKarpenterResources(ctx context.Co
602
601
// Delete NodePool
603
602
nodePoolGVR := schema.GroupVersionResource {
604
603
Group : "karpenter.sh" ,
605
- Version : "v1beta1 " ,
604
+ Version : "v1 " ,
606
605
Resource : "nodepools" ,
607
606
}
608
607
@@ -619,7 +618,7 @@ func (r *KarpenterMachinePoolReconciler) deleteKarpenterResources(ctx context.Co
619
618
// Delete EC2NodeClass
620
619
ec2NodeClassGVR := schema.GroupVersionResource {
621
620
Group : "karpenter.k8s.aws" ,
622
- Version : "v1beta1 " ,
621
+ Version : "v1 " ,
623
622
Resource : "ec2nodeclasses" ,
624
623
}
625
624
0 commit comments