@@ -28,9 +28,11 @@ import (
2828 "github.com/functions-dev/func-operator/internal/git"
2929 "github.com/functions-dev/func-operator/internal/monitoring"
3030 "sigs.k8s.io/controller-runtime/pkg/cache"
31+ "sigs.k8s.io/controller-runtime/pkg/client"
3132
3233 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
3334 // to ensure that exec-entrypoint and run can make use of them.
35+ v1 "k8s.io/api/core/v1"
3436 _ "k8s.io/client-go/plugin/pkg/client/auth"
3537
3638 "k8s.io/apimachinery/pkg/runtime"
@@ -196,6 +198,12 @@ func main() {
196198 })
197199 }
198200
201+ operatorNamespace := os .Getenv ("SYSTEM_NAMESPACE" )
202+ if operatorNamespace == "" {
203+ setupLog .Info ("Operator namespace not set, defaulting to func-operator-system" )
204+ operatorNamespace = "func-operator-system"
205+ }
206+
199207 watchNamespaces := getWatchNamespaces ()
200208 var cacheOpts cache.Options
201209 if len (watchNamespaces ) > 0 {
@@ -210,6 +218,16 @@ func main() {
210218 setupLog .Info ("Operator watching all namespaces" )
211219 }
212220
221+ // Always watch ConfigMaps in the operator's namespace so it can access the controller-config ConfigMap,
222+ // without affecting which namespaces Functions are watched in
223+ cacheOpts .ByObject = map [client.Object ]cache.ByObject {
224+ & v1.ConfigMap {}: {
225+ Namespaces : map [string ]cache.Config {
226+ operatorNamespace : {},
227+ },
228+ },
229+ }
230+
213231 mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
214232 Scheme : scheme ,
215233 Metrics : metricsServerOptions ,
@@ -251,12 +269,6 @@ func main() {
251269 }
252270 setupLog .Info ("Func CLI is ready" )
253271
254- operatorNamespace := os .Getenv ("SYSTEM_NAMESPACE" )
255- if operatorNamespace == "" {
256- setupLog .Info ("Operator namespace not set, defaulting to func-operator-system" )
257- operatorNamespace = "func-operator-system"
258- }
259-
260272 if err := (& controller.FunctionReconciler {
261273 Client : mgr .GetClient (),
262274 Scheme : mgr .GetScheme (),
0 commit comments