Skip to content

Commit db1001c

Browse files
committed
Add some docs
1 parent e577ed7 commit db1001c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

docs/book/src/developer/architecture/controllers/support-multiple-instances.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ in case the above limitations/extra complexity are acceptable for them.
2424
In order to make it possible for users to deploy multiple instances of the same provider:
2525

2626
- Providers MUST support the `--namespace` flag in their controllers.
27+
- Providers MUST support the `--watch-filter` flag in their controllers.
2728

2829
⚠️ Users selecting this deployment model, please be aware:
2930

docs/book/src/developer/providers/v1alpha3-to-v1alpha4.md

+25
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ see [Multi-tenancy](../architecture/controllers/multi-tenancy.md) and [Support m
5454
more details.
5555

5656
Specific changes related to this topic will be detailed in this document.
57+
58+
## Support the cluster.x-k8s.io/watch-filter label and watch-filter flag.
59+
60+
- A new label `cluster.x-k8s.io/watch-filter` provides the ability to filter the controllers to only reconcile objects with a specific label.
61+
- A new flag `watch-filter` enables users to specify the label value for the `cluster.x-k8s.io/watch-filter` label on controller boot.
62+
- The flag which enables users to set the flag value can be structured like this:
63+
```go
64+
fs.StringVar(&watchFilterValue, "watch-filter", "", fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
65+
```
66+
- The `ResourceNotPausedAndHasFilterLabel` predicate is a useful helper to check for the pause annotation and the filter label easily:
67+
```go
68+
c, err := ctrl.NewControllerManagedBy(mgr).
69+
For(&clusterv1.MachineSet{}).
70+
Owns(&clusterv1.Machine{}).
71+
Watches(
72+
&source.Kind{Type: &clusterv1.Machine{}},
73+
handler.EnqueueRequestsFromMapFunc(r.MachineToMachineSets),
74+
).
75+
WithOptions(options).
76+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
77+
Build(r)
78+
if err != nil {
79+
return errors.Wrap(err, "failed setting up with a controller manager")
80+
}
81+
```

0 commit comments

Comments
 (0)