@@ -13,8 +13,6 @@ The kubeconfig provider allows you to:
13
13
14
14
```
15
15
examples/kubeconfig/
16
- ├── controllers/ # Example controller that simply lists pods
17
- │ ├── pod_lister.go
18
16
├── scripts/ # Utility scripts
19
17
│ └── create-kubeconfig-secret.sh
20
18
└── main.go # Example operator implementation
@@ -62,7 +60,7 @@ metadata:
62
60
rules :
63
61
# Add permissions for your operator <--------------------------------
64
62
- apiGroups : [""]
65
- resources : ["pods "]
63
+ resources : ["configmaps "]
66
64
verbs : ["list", "get", "watch"] # watch is needed for controllers that observe resources
67
65
` ` `
68
66
@@ -78,17 +76,16 @@ Add your controllers to `main.go`:
78
76
79
77
` ` ` go
80
78
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
+ ))
92
89
}
93
90
` ` `
94
91
0 commit comments