Skip to content
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

Extend APIServerSource to watch multiple namespaces #6644

Closed
gab-satchi opened this issue Dec 9, 2022 · 2 comments · Fixed by #6665
Closed

Extend APIServerSource to watch multiple namespaces #6644

gab-satchi opened this issue Dec 9, 2022 · 2 comments · Fixed by #6665

Comments

@gab-satchi
Copy link
Contributor

Problem
There's a bit of overhead if a user wishes to watch multiple namespaces for api server events. They currently need to create an APIServerSource for each of the namespaces they wish to watch.

This issue is to explore a solution where multiple namespaces can be watched with a single APIServerSource. There was an issue about watching a different namespace but this issue extends that a step further.

One possible solution would be to introduce a label selector to the api. If it's not set, it could default to just watching the namespace the source resides in to maintain backwards compatibility. An empty selector can mean all namespaces. This would be similar to how the sugar controller configuration is done.

Persona:
Which persona is this feature for?
System integrator

Additional context (optional)
The permissions checker and the receiver adapter will need to iterate over all namespaces

@pierDipi
Copy link
Member

pierDipi commented Jan 4, 2023

I don't have concerns for the feature itself, one question below

One possible solution would be to introduce a label selector to the api. If it's not set, it could default to just watching the namespace the source resides in to maintain backwards compatibility. An empty selector can mean all namespaces. This would be similar to how the sugar controller configuration is done.

What all selected namespaces would mean? at the creation time? or are we planning to watch namespaces as they are created or deleted to dynamically watch resources in selected namespaces?

@gab-satchi
Copy link
Contributor Author

I think this problem would exist even when a selector is used. The namespaces targeted can change dynamically.

I was thinking about the FilteredGlobalResync but I don't know if that could be used. When a label is removed from a namespace, it can't tell which api sources used to watch the namespace. I think a GlobalResync might be the most thorough option. So whenever a namespace event happens, we enqueue all the api sources.

knative-prow bot pushed a commit that referenced this issue Jan 25, 2023
Fixes #6644 

## Proposed Changes

<!-- Please categorize your changes:
- 🎁 Add new feature
- 🐛 Fix bug
- 🧹 Update or clean up current behavior
- 🗑️ Remove feature or internal logic
-->

- 🎁 ApiServerSource can specify a selector to target one or more
namespaces. If the selector is missing, it will default to targeting the
namespace in which the source resides

API changes (additive):
- `spec.namespaceSelector`: A label selector to identify namespaces to
track
- `status.namespaces`: A list of namespaces currently being tracked by
the source


### Pre-review Checklist

<!-- If these boxes are not checked, you will be asked to complete these
requirements or explain why they do not apply to your PR. -->

- [ ] **At least 80% unit test coverage**
- [ ] **E2E tests** for any new behavior
- [ ] **Docs PR** for any user-facing impact
- [ ] **Spec PR** for any new API feature
- [ ] **Conformance test** for any change to the spec

**Release Note**

<!--
📄 If this change has user-visible impact, write a release
note in the block
below. Include the string "action required" if additional action is
required of
users switching to the new release, for example in case of a breaking
change.

Write as if you are speaking to users, not other Knative contributors.
If this
change has no user-visible impact, no release note is needed.
-->

```release-note
📄 ApiServerSource can specify a selector to target one or more namespaces. If the selector is missing, it will default to targeting the namespace in which the source resides
```


**Docs**

Docs to follow once the behaviour is finalized and approved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants