Skip to content

Commit aeb8e3e

Browse files
committed
Match on node group by names from spec
1 parent a2a4c4b commit aeb8e3e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

api/v1alpha2/nodegroup_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323

2424
type NodeGroupSpec struct {
2525
//+optional
26-
Members []string `json:"members,omitempty"`
26+
Members []string `json:"members"`
2727
//+optional
28-
NodeGroupNames []string `json:"nodeGroupNames,omitempty"`
28+
NodeGroupNames []string `json:"nodeGroupNames"`
2929
//+optional
3030
Labels map[string]string `json:"labels,omitEmpty"`
3131
//+optional

controllers/nodegroup_controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ func (r *NodeGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
174174
}
175175

176176
matchingStrings := nodeGroup.Spec.Members
177+
nodes := &corev1.NodeList{}
178+
if err := r.List(ctx, nodes); err != nil {
179+
log.Error(err, "unable to list Nodes")
180+
return ctrl.Result{}, err
181+
}
182+
183+
for _, node := range nodes.Items {
184+
if stringIn(node.Name, nodeGroup.Spec.NodeGroupNames) {
185+
matchingStrings = append(matchingStrings, node.Name)
186+
}
187+
}
177188

178189
node := &corev1.Node{}
179190

0 commit comments

Comments
 (0)