You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(operator)!: support multiple controllers and selectors per entity (#1183)
## Summary
Add support for multiple controllers targeting the same entity type.
- Add `[LabelSelector]` and `[FieldSelector]` controller attributes.
- Add generator error `KOG001` for conflicting selector attributes.
- Add `WatchStrategy.PerController` and the opt-in `SharedPerEntity`
strategy.
- Add client-side selector matching through
`IClientSideEntitySelector<TEntity>`.
- Give each controller its own watcher, queue, and reconciliation
pipeline.
- Share parallelism limits and per-UID locking across controller
pipelines.
- Route `EntityQueue<TEntity>` requeues to the active controller
pipeline.
- Aggregate queue-depth metrics per entity type.
- Reject multiple controllers when using custom queue or leader-election
strategies.
- Update tests, migration guidance, and operator documentation.
Closes#909.
## Breaking changes
- Remove `IEntityQueueFactory` and `EntityQueueFactory`. Use
reconciliation results or the scoped `EntityQueue<TEntity>` delegate for
requeues.
- Add the required `OperatorSettings.WatchStrategy` property. Prefer
`OperatorSettingsBuilder`, which supplies the default `PerController`
strategy.
- Stop registering `IReconciler<TEntity>` and
`ITimedEntityQueue<TEntity>` in DI for the default in-memory pipeline.
- Resolving `EntityQueue<TEntity>` outside a reconciliation scope is
ambiguous and throws when multiple controller pipelines exist.
- Add a `cachePartition` parameter to custom `ResourceWatcher<TEntity>`
and `LeaderAwareResourceWatcher<TEntity>` constructors.
- Add `IEntityReconcileCoordinator<TEntity>` to custom
queue-background-service constructors.
- Add the concrete controller type to direct `Reconciler<TEntity>`
construction.
- Report controllers declaring both `[LabelSelector]` and
`[FieldSelector]` as generator error `KOG001`.
Copy file name to clipboardExpand all lines: docs/docs/operator/building-blocks/controllers.mdx
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,8 @@ flowchart TB
80
80
81
81
The `requeueAfter` path (dashed) is triggered when your controller returns a `ReconciliationResult` with a non-zero `RequeueAfter` value.
82
82
83
+
KubeOps creates one such pipeline — watcher, queue, and background service — **per registered controller**. Multiple controllers for the same entity type (for example with different label selectors) therefore run fully independent pipelines that never suppress each other's events — see [Multiple Controllers per Entity](#multiple-controllers-per-entity). With the opt-in `WatchStrategy.SharedPerEntity`, a single shared watcher per entity type replaces the per-controller watchers and dispatches each event to all pipelines whose label selectors match — see [Watch Strategy](../configuration/watch-strategy) for the trade-offs.
84
+
83
85
## Reconciliation Loop
84
86
85
87
The reconciliation loop is the core of your operator's functionality. It consists of two main methods:
@@ -452,6 +454,73 @@ When no field selector is needed, the built-in `DefaultEntityFieldSelector<TEnti
0 commit comments