Is your feature request related to a problem? Please describe.
Currently, Kubernetes fieldSelector only supports = and != operations. This makes it impossible to query multiple resources by their names in a single request.
For example, the following does not work:
kubectl get pods --field-selector=metadata.name in (pod1, pod2, pod3)
nginx
复制代码
The API returns an error:
invalid selector: ‘metadata.name in (pod1, pod2, pod3)’; can’t understand ’ pod2, pod3)’
markdown
复制代码
Describe the solution you’d like
Add support for in and notin operators for metadata.name in fieldSelector. This would allow querying multiple objects by name in a single API call, improving efficiency and reducing the need for multiple requests or client-side filtering.
Example usage:
kubectl get pods --field-selector=metadata.name in (pod1, pod2, pod3)
markdown
复制代码
Describe alternatives you’ve considered
- Multiple separate requests:
kubectl get pods --field-selector=metadata.name=pod1
kubectl get pods --field-selector=metadata.name=pod2
kubectl get pods --field-selector=metadata.name=pod3
markdown
复制代码
- Inefficient and cumbersome for large numbers of objects.
- Use labels to tag objects with unique identifiers and then
labelSelectorwithin.- Adds unnecessary complexity and duplication.
Additional context
Supporting metadata.name in (...) would make fieldSelector much more practical for real-world o