Skip to content

Commit e87d502

Browse files
committed
Add managed-by label to resources created by controller
1 parent 810a7b3 commit e87d502

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

controllers/karpentermachinepool_controller.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateEC2NodeClass(ctx context.
411411
ec2NodeClass := &unstructured.Unstructured{}
412412
ec2NodeClass.SetGroupVersionKind(ec2NodeClassGVR.GroupVersion().WithKind("EC2NodeClass"))
413413
ec2NodeClass.SetName(karpenterMachinePool.Name)
414-
ec2NodeClass.SetNamespace("default")
414+
ec2NodeClass.SetNamespace("")
415+
ec2NodeClass.SetLabels(map[string]string{"app.kubernetes.io/managed-by": "aws-resolver-rules-operator"})
415416

416417
// Generate user data for Ignition
417418
userData := r.generateUserData(awsCluster.Spec.S3Bucket.Name, cluster.Name, karpenterMachinePool.Name)
@@ -526,7 +527,8 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
526527
nodePool := &unstructured.Unstructured{}
527528
nodePool.SetGroupVersionKind(nodePoolGVR.GroupVersion().WithKind("NodePool"))
528529
nodePool.SetName(karpenterMachinePool.Name)
529-
nodePool.SetNamespace("default")
530+
nodePool.SetNamespace("")
531+
nodePool.SetLabels(map[string]string{"app.kubernetes.io/managed-by": "aws-resolver-rules-operator"})
530532

531533
// Set default requirements and overwrite with the user provided configuration
532534
requirements := []map[string]interface{}{
@@ -572,6 +574,8 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
572574
requirements = append(requirements, requirement)
573575
}
574576
}
577+
nodePool.SetNamespace("")
578+
nodePool.SetLabels(map[string]string{"app.kubernetes.io/managed-by": "aws-resolver-rules-operator"})
575579

576580
// Set default labels and overwrite with the user provided configuration
577581
labels := map[string]string{
@@ -603,7 +607,7 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
603607
"value": "true",
604608
},
605609
},
606-
"requirements": requirements,
610+
"requirements": karpenterMachinePool.Spec.NodePool.Template.Spec.Requirements,
607611
"nodeClassRef": map[string]interface{}{
608612
"group": "karpenter.k8s.aws",
609613
"kind": "EC2NodeClass",

0 commit comments

Comments
 (0)