Skip to content

Commit 2a79c2a

Browse files
committed
Add some docs
1 parent e149087 commit 2a79c2a

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
@@ -58,3 +58,28 @@ Specific changes related to this topic will be detailed in this document.
5858
## Change types with arrays of pointers to custom objects
5959

6060
The conversion-gen code from the `1.20.x` release onward generates incorrect conversion functions for types having arrays of pointers to custom objects. Change the existing types to contain objects instead of pointer references.
61+
62+
## Support the cluster.x-k8s.io/watch-filter label and watch-filter flag.
63+
64+
- A new label `cluster.x-k8s.io/watch-filter` provides the ability to filter the controllers to only reconcile objects with a specific label.
65+
- A new flag `watch-filter` enables users to specify the label value for the `cluster.x-k8s.io/watch-filter` label on controller boot.
66+
- The flag which enables users to set the flag value can be structured like this:
67+
```go
68+
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))
69+
```
70+
- The `ResourceNotPausedAndHasFilterLabel` predicate is a useful helper to check for the pause annotation and the filter label easily:
71+
```go
72+
c, err := ctrl.NewControllerManagedBy(mgr).
73+
For(&clusterv1.MachineSet{}).
74+
Owns(&clusterv1.Machine{}).
75+
Watches(
76+
&source.Kind{Type: &clusterv1.Machine{}},
77+
handler.EnqueueRequestsFromMapFunc(r.MachineToMachineSets),
78+
).
79+
WithOptions(options).
80+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
81+
Build(r)
82+
if err != nil {
83+
return errors.Wrap(err, "failed setting up with a controller manager")
84+
}
85+
```

0 commit comments

Comments
 (0)