-
Notifications
You must be signed in to change notification settings - Fork 274
KREP-003: Decorators (Collection Watching) #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ellistarn The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
b52060c to
012afa1
Compare
n3wscott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, I think you can flatten the API a little.
| // +kubebuilder:validation:Required | ||
| Kind string `json:"kind"` | ||
| // +kubebuilder:validation:Optional # <---- Mutually exclusive with Selector, NamespaceSelector | ||
| Metadata ExternalRefMetadata `json:"metadata"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if selector had an optional "Namespace" field to continue filtering labeled resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the full semantics to do things like opt namespaces in by label. Can you be a hair more concrete about what you're proposing? Structs?
|
|
||
| ## Proposed API and Behavior Changes | ||
|
|
||
| 1. Introduce `Selector` and `NamespaceSelector` to `ExternalRef` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when using Selector and NamespaceSelector, there is even more reason to keep it as Reference because even Kubernetes calls it reference
| 2. Make `Metadata` optional and mutually exclusive with `Selector` and `NamespaceSelector` | ||
| 3. `Kind` must refer to a `ListKind` when `Metadata` is not defined (e.g. `DeploymentList`) | ||
| 4. If `Metadata` is defined, `ExternalRef` refers to a single resource, otherwise it refers to a | ||
| collection of resources | ||
| 5. Both `Selector` and `NamespaceSelector` are optional, and if omitted, all resources are included |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure I get the difference between Selector and NamespaceSelector
What would be in Metadata that makes it impossible to craft a good Selector?
I smell that we would gain simplicity by having a single Selector to filter object of Kind whether it's a namespace or any other object.
There is another question, whether it is allowed, to watch resources from other namespaces (or cluster-wide for namespaced RGDs).
Maybe we can inspire from NetworkPolicies and define:
NamespaceSelector a selector to match namespace labels in which the resource should be
Selector a selector to match the resource labels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example from NetworkPolicies is exactly what I was thinking. The NamespaceSelector constrains what Namespaces we look at and the regular Selector constrains the individual objects by label.
namespaceSelector: # Only include namespaces with the opt-in label
matchLabels:
"opt-in-namespace": true
selector:
matchLabels
"opt-in-object": true
In this example, you would only include objects that are opted in in both their own metadata.labels, as well as the metadata.labels of the namespace. e.g.
kind: Namespace
metadata:
labels:
"opt-in-namespace": true
...
---
kind: Object
metadata:
labels:
"opt-in-object": true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why having metadata? for backward compatibility?
|
@ellistarn: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
KREP-003 introduces Decorators (a.k.a Collection Watching), an extension of Collections and ExternalRefs. We extend
externalRefto support watching a collection of objects, rather than just a single object.See the full proposal here: https://github.com/ellistarn/kro/blob/krep/docs/design/proposals/decorators.md