@@ -51,7 +51,7 @@ var ErrIgnored = errors.New("ignored resource")
51
51
type K8s interface {
52
52
GetRestClientset () client.Client
53
53
GetClientset () * k8sclientset.Clientset
54
- MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {})
54
+ MonitorChanges (eventChan chan SyncDataEvent , stop chan struct {}, osArgs utils. OSArgs )
55
55
UpdatePublishService (ingresses []* ingress.Ingress , publishServiceAddresses []string )
56
56
}
57
57
@@ -77,7 +77,6 @@ type k8s struct {
77
77
syncPeriod time.Duration
78
78
cacheResyncPeriod time.Duration
79
79
disableSvcExternalName bool // CVE-2021-25740
80
- gatewayCRDInstalled bool
81
80
}
82
81
83
82
func 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
146
145
}
147
146
}
148
147
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 ) {
150
149
informersSynced := & []cache.InformerSynced {}
151
- k . gatewayCRDInstalled = k .isGatewayAPIInstalled ()
150
+ needGatewayAPIInformers : = k .isGatewayAPIInstalled () && osArgs . GatewayControllerName != ""
152
151
k .runPodInformer (eventChan , stop , informersSynced )
153
152
for _ , namespace := range k .whiteListedNS {
154
153
k .runInformers (eventChan , stop , namespace , informersSynced )
155
154
k .runCRInformers (eventChan , stop , namespace , informersSynced )
156
- k .runInformersGwAPI (eventChan , stop , namespace , informersSynced )
155
+ if needGatewayAPIInformers {
156
+ k .runInformersGwAPI (eventChan , stop , namespace , informersSynced )
157
+ }
157
158
}
158
159
159
160
if ! cache .WaitForCacheSync (stop , * informersSynced ... ) {
@@ -234,9 +235,6 @@ func (k k8s) runInformers(eventChan chan SyncDataEvent, stop chan struct{}, name
234
235
}
235
236
236
237
func (k k8s ) runInformersGwAPI (eventChan chan SyncDataEvent , stop chan struct {}, namespace string , informersSynced * []cache.InformerSynced ) {
237
- if ! k .gatewayCRDInstalled {
238
- return
239
- }
240
238
factory := gatewaynetworking .NewSharedInformerFactoryWithOptions (k .gatewayClient , k .cacheResyncPeriod , gatewaynetworking .WithNamespace (namespace ))
241
239
gwclassInf := k .getGatewayClassesInformer (eventChan , factory )
242
240
if gwclassInf != nil {
0 commit comments