Skip to content

Commit 558cd9f

Browse files
docs: remove pod watcher controller and use builder as example
1 parent f40b8f6 commit 558cd9f

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

examples/kubeconfig/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ The kubeconfig provider allows you to:
1313

1414
```
1515
examples/kubeconfig/
16-
├── controllers/ # Example controller that simply lists pods
17-
│ ├── pod_lister.go
1816
├── scripts/ # Utility scripts
1917
│ └── create-kubeconfig-secret.sh
2018
└── main.go # Example operator implementation
@@ -62,7 +60,7 @@ metadata:
6260
rules:
6361
# Add permissions for your operator <--------------------------------
6462
- apiGroups: [""]
65-
resources: ["pods"]
63+
resources: ["configmaps"]
6664
verbs: ["list", "get", "watch"] # watch is needed for controllers that observe resources
6765
```
6866
@@ -78,17 +76,16 @@ Add your controllers to `main.go`:
7876

7977
```go
8078
func main() {
81-
// Import your controllers here <--------------------------------
82-
"sigs.k8s.io/multicluster-runtime/examples/kubeconfig/controllers"
83-
84-
//...
85-
86-
// Run your controllers here <--------------------------------
87-
podWatcher := controllers.NewPodWatcher(mgr)
88-
if err := mgr.Add(podWatcher); err != nil {
89-
entryLog.Error(err, "Unable to add pod watcher")
90-
os.Exit(1)
91-
}
79+
err = mcbuilder.ControllerManagedBy(mgr).
80+
Named("multicluster-configmaps").
81+
For(&corev1.ConfigMap{}). // object to watch
82+
Complete(mcreconcile.Func(
83+
func(ctx context.Context, req mcreconcile.Request) (ctrl.Result, error) {
84+
// reconcile logic
85+
86+
return ctrl.Result{}, nil
87+
},
88+
))
9289
}
9390
```
9491

examples/kubeconfig/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func main() {
7979
os.Exit(1)
8080
}
8181

82+
// Create a controller that watches ConfigMaps and logs when they are found.
8283
err = mcbuilder.ControllerManagedBy(mgr).
8384
Named("multicluster-configmaps").
8485
For(&corev1.ConfigMap{}).

0 commit comments

Comments
 (0)