Skip to content

Commit

Permalink
Reduce mt-broker-controller memory usage with namespaced endpoint inf…
Browse files Browse the repository at this point in the history
…ormer (knative#8418) (#1012)

* Reduce mt-broker-controller memory usage with namespaced endpoint informer

Currently, the mt-broker-controller is using a cluster-wide endpoints
informer but it actually only uses endpoints in the "SYSTEM_NAMESPACE".

Using the namespaced informer factory ensures that the watcher
is only watching endpoints in the `knative-eventing` (also known as
`SYSTEM_NAMESPACE`) namespace.



* Start informer



---------

Signed-off-by: Pierangelo Di Pilato <[email protected]>
Co-authored-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
openshift-cherrypick-robot and pierDipi authored Jan 29, 2025
1 parent bf54a53 commit 125b0dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/reconciler/broker/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"k8s.io/client-go/tools/cache"
"knative.dev/pkg/apis"
configmapinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/configmap"
endpointsinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/endpoints"
"knative.dev/pkg/configmap"
"knative.dev/pkg/controller"
"knative.dev/pkg/injection/clients/dynamicclient"
secretinformer "knative.dev/pkg/injection/clients/namespacedkube/informers/core/v1/secret"
namespacedinformerfactory "knative.dev/pkg/injection/clients/namespacedkube/informers/factory"
"knative.dev/pkg/logging"
pkgreconciler "knative.dev/pkg/reconciler"
"knative.dev/pkg/resolver"
Expand Down Expand Up @@ -69,7 +69,12 @@ func NewController(
logger := logging.FromContext(ctx)
brokerInformer := brokerinformer.Get(ctx)
subscriptionInformer := subscriptioninformer.Get(ctx)
endpointsInformer := endpointsinformer.Get(ctx)

endpointsInformer := namespacedinformerfactory.Get(ctx).Core().V1().Endpoints()
if err := controller.StartInformers(ctx.Done(), endpointsInformer.Informer()); err != nil {
logger.Fatalw("Failed to start namespaced endpoints informer", zap.Error(err))
}

configmapInformer := configmapinformer.Get(ctx)
secretInformer := secretinformer.Get(ctx)
eventPolicyInformer := eventpolicyinformer.Get(ctx)
Expand Down

0 comments on commit 125b0dc

Please sign in to comment.