@@ -51,7 +51,7 @@ var ErrIgnored = errors.New("ignored resource")
5151type K8s interface {
5252 GetRestClientset () client.Client
5353 GetClientset () * k8sclientset.Clientset
54- MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {})
54+ MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {}, osArgs utils. OSArgs )
5555 UpdatePublishService (ingresses []* ingress.Ingress , publishServiceAddresses []string )
5656}
5757
@@ -77,7 +77,6 @@ type k8s struct {
7777 syncPeriod time.Duration
7878 cacheResyncPeriod time.Duration
7979 disableSvcExternalName bool // CVE-2021-25740
80- gatewayCRDInstalled bool
8180}
8281
8382func New (osArgs utils.OSArgs , whitelist map [string ]struct {}, publishSvc * utils.NamespaceValue ) K8s { //nolint:ireturn
@@ -146,14 +145,16 @@ func (k k8s) UpdatePublishService(ingresses []*ingress.Ingress, publishServiceAd
146145 }
147146}
148147
149- func (k k8s ) MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {}) {
148+ func (k k8s ) MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {}, osArgs utils. OSArgs ) {
150149 informersSynced := & []cache.InformerSynced {}
151- k . gatewayCRDInstalled = k .isGatewayAPIInstalled ()
150+ needGatewayAPIInformers : = k .isGatewayAPIInstalled () && osArgs . GatewayControllerName != ""
152151 k .runPodInformer (eventChan , stop , informersSynced )
153152 for _ , namespace := range k .whiteListedNS {
154153 k .runInformers (eventChan , stop , namespace , informersSynced )
155154 k .runCRInformers (eventChan , stop , namespace , informersSynced )
156- k .runInformersGwAPI (eventChan , stop , namespace , informersSynced )
155+ if needGatewayAPIInformers {
156+ k .runInformersGwAPI (eventChan , stop , namespace , informersSynced )
157+ }
157158 }
158159
159160 if ! cache .WaitForCacheSync (stop , * informersSynced ... ) {
@@ -234,9 +235,6 @@ func (k k8s) runInformers(eventChan chan SyncDataEvent, stop chan struct{}, name
234235}
235236
236237func (k k8s ) runInformersGwAPI (eventChan chan SyncDataEvent , stop chan struct {}, namespace string , informersSynced * []cache.InformerSynced ) {
237- if ! k .gatewayCRDInstalled {
238- return
239- }
240238 factory := gatewaynetworking .NewSharedInformerFactoryWithOptions (k .gatewayClient , k .cacheResyncPeriod , gatewaynetworking .WithNamespace (namespace ))
241239 gwclassInf := k .getGatewayClassesInformer (eventChan , factory )
242240 if gwclassInf != nil {
0 commit comments