kubernetes / kubernetes/kubernetes
Reverse lookup by labels
- Dominant language
- Go
- Stars
- 128k
- Forks
- 44.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 208
Description
LIST queries can be filtered by label selector.
It should also be possible to filter LISTs of replication controllers and services by _labels_. What this would do is return objects whose label selectors matched the specified labels. This would make it straightforward to figure out which service(s) targeted a particular pod, for instance, without creating a single label applied to both, which kubecfg currently does for its simple use case, but is an anti-pattern in the general case. Clients should apply the same labels to services as to the pods they control, but pods likely will carry a superset of the service labels.
Note that this functionality (though not the same API) is also needed in order to implement Watch of pods filtered by a label selector, since newly created pods need to be matched against outstanding Watches. It would also be useful to validate that there's at most one replication controller targeting a given pod at a time.
This may be a bit confusing right now, because label selectors look like sets of labels, and even use the parameter name "labels" in LIST queries, but really aren't labels, esp. once selectors are generalized (#341). I suggest we change that parameter to "selector" and use "labels" for this proposal. The "labels" parameter would only be valid for API objects containing selectors.
/cc @lavalamp
Contributor guide
Research direction
Start by tracing how LIST queries and label selectors are represented for replication controllers and services. Define the proposed distinction between the existing selector parameter and the new labels parameter, then determine how matching should support reverse lookup, watches, and validation; the issue provides no file or test names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100