Skip to content

Commit

Permalink
Limit configmap/deployment cache by CommonLabels
Browse files Browse the repository at this point in the history
  • Loading branch information
Baarsgaard committed Jan 11, 2025
1 parent fbc0b9e commit e09ad71
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"

v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/cache"

Expand All @@ -46,6 +47,7 @@ import (
grafanav1beta1 "github.com/grafana/grafana-operator/v5/api/v1beta1"
"github.com/grafana/grafana-operator/v5/controllers"
"github.com/grafana/grafana-operator/v5/controllers/autodetect"
"github.com/grafana/grafana-operator/v5/controllers/model"
"github.com/grafana/grafana-operator/v5/embeds"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -118,6 +120,16 @@ func main() {
LeaderElection: enableLeaderElection,
LeaderElectionID: "f75f3bba.integreatly.org",
PprofBindAddress: pprofAddr,
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
&corev1.ConfigMap{}: {
Label: labels.SelectorFromSet(model.CommonLabels),
},
&v1.Deployment{}: {
Label: labels.SelectorFromSet(model.CommonLabels),
},
},
},
}

getNamespaceConfig := func(namespaces string) map[string]cache.Config {
Expand Down

0 comments on commit e09ad71

Please sign in to comment.