kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
9.13k stars 2.95k forks source link

FieldSelector doesn't appear to be filtering properly #1350

Open jacobwolfaws opened 7 months ago

jacobwolfaws commented 7 months ago

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

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

jacobwolfaws commented 4 months ago

/remove-lifecycle stale

k8s-triage-robot commented 1 month ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten