client-go
client-go copied to clipboard
FieldSelector doesn't appear to be filtering properly
I'm trying to filter a list of pods based on the node they're on:
podList, err := clientset.CoreV1().Pods("").List(context.Background(), metav1.ListOptions{
FieldSelector: fmt.Sprintf("spec.nodeName=%s", nodeName),
})
but the FieldSelector doesn't appear to be filtering them properly. I'm currently working around this by doing:
for _, pod := range podList.Items {
if pod.Spec.NodeName == nodeName {
# Take action here
}
}
slack thread: https://kubernetes.slack.com/archives/C0EG7JC6T/p1713547391787689?thread_ts=1713212213.662529&cid=C0EG7JC6T