@@ -25,8 +25,12 @@ import (
25
25
"os"
26
26
"time"
27
27
28
+ "github.com/operator-framework/operator-controller/internal/labels"
29
+
28
30
"github.com/spf13/pflag"
29
31
"go.uber.org/zap/zapcore"
32
+ k8slabels "k8s.io/apimachinery/pkg/labels"
33
+ "k8s.io/apimachinery/pkg/selection"
30
34
_ "k8s.io/client-go/plugin/pkg/client/auth"
31
35
ctrl "sigs.k8s.io/controller-runtime"
32
36
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -39,12 +43,14 @@ import (
39
43
"github.com/operator-framework/rukpak/pkg/storage"
40
44
"github.com/operator-framework/rukpak/pkg/util"
41
45
46
+ "github.com/operator-framework/operator-controller/api/v1alpha1"
42
47
"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
43
48
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
44
49
"github.com/operator-framework/operator-controller/internal/controllers"
45
50
"github.com/operator-framework/operator-controller/internal/handler"
46
51
"github.com/operator-framework/operator-controller/pkg/features"
47
52
"github.com/operator-framework/operator-controller/pkg/scheme"
53
+ crcache "sigs.k8s.io/controller-runtime/pkg/cache"
48
54
)
49
55
50
56
var (
@@ -83,13 +89,33 @@ func main() {
83
89
84
90
ctrl .SetLogger (zap .New (zap .UseFlagOptions (& opts ), zap .StacktraceLevel (zapcore .DPanicLevel )))
85
91
92
+ if systemNamespace == "" {
93
+ systemNamespace = util .PodNamespace ()
94
+ }
95
+
96
+ dependentRequirement , err := k8slabels .NewRequirement (labels .OwnerKindKey , selection .In , []string {v1alpha1 .ClusterExtensionKind })
97
+ if err != nil {
98
+ setupLog .Error (err , "unable to create dependent label selector for cache" )
99
+ os .Exit (1 )
100
+ }
101
+ dependentSelector := k8slabels .NewSelector ().Add (* dependentRequirement )
102
+
86
103
fmt .Println ("set up manager" )
87
104
mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
88
105
Scheme : scheme .Scheme ,
89
106
Metrics : server.Options {BindAddress : metricsAddr },
90
107
HealthProbeBindAddress : probeAddr ,
91
108
LeaderElection : enableLeaderElection ,
92
109
LeaderElectionID : "9c4404e7.operatorframework.io" ,
110
+ Cache : crcache.Options {
111
+ ByObject : map [client.Object ]crcache.ByObject {
112
+ & v1alpha1.ClusterExtension {}: {},
113
+ },
114
+ DefaultNamespaces : map [string ]crcache.Config {
115
+ systemNamespace : {},
116
+ crcache .AllNamespaces : {LabelSelector : dependentSelector },
117
+ },
118
+ },
93
119
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
94
120
// when the Manager ends. This requires the binary to immediately end when the
95
121
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
@@ -124,10 +150,6 @@ func main() {
124
150
os .Exit (1 )
125
151
}
126
152
127
- if systemNamespace == "" {
128
- systemNamespace = util .PodNamespace ()
129
- }
130
-
131
153
unpacker , err := source .NewDefaultUnpacker (mgr , systemNamespace , unpackImage , (* x509 .CertPool )(nil ))
132
154
if err != nil {
133
155
setupLog .Error (err , "unable to create unpacker" )
0 commit comments