Is there a way to get all nodes in go client filtered by NodeSelectorTerms?

95 Views Asked by At

I have a nodeSelectorTerms that I pass to pod spec to set nodeAffinity. In the other part of my project, I like to list all nodes that match those terms. Is there any solution to this?

I want some thing like this:

    nodeList := &corev1.NodeList{}
    if err := r.Client.List(context.Background(), nodeList, &client.Selector{config.NodeSelectorTerms}); err != nil {
        return nil, err
    }
    return nodeList, nil
0

There are 0 best solutions below