@@ -62,6 +62,13 @@ func (r *GatewayProxyController) SetupWithManager(mrg ctrl.Manager) error {
6262 // Check and store EndpointSlice API support
6363 r .supportsEndpointSlice = pkgutils .HasAPIResource (mrg , & discoveryv1.EndpointSlice {})
6464 r .supportsGateway = pkgutils .HasAPIResource (mrg , & gatewayv1.Gateway {})
65+ var icWatch client.Object
66+ switch r .ICGV .String () {
67+ case networkingv1beta1 .SchemeGroupVersion .String ():
68+ icWatch = & networkingv1beta1.IngressClass {}
69+ default :
70+ icWatch = & networkingv1.IngressClass {}
71+ }
6572
6673 eventFilters := []predicate.Predicate {
6774 predicate.GenerationChangedPredicate {},
@@ -77,6 +84,10 @@ func (r *GatewayProxyController) SetupWithManager(mrg ctrl.Manager) error {
7784 WithEventFilter (predicate .Or (eventFilters ... )).
7885 Watches (& corev1.Service {},
7986 handler .EnqueueRequestsFromMapFunc (r .listGatewayProxiesForProviderService ),
87+ ).
88+ Watches (
89+ icWatch ,
90+ handler .EnqueueRequestsFromMapFunc (r .listGatewayProxiesForIngressClass ),
8091 )
8192
8293 // Conditionally watch EndpointSlice or Endpoints based on cluster API support
@@ -85,6 +96,12 @@ func (r *GatewayProxyController) SetupWithManager(mrg ctrl.Manager) error {
8596 r .listGatewayProxiesForProviderEndpoints ,
8697 r .Log )
8798
99+ if r .supportsGateway {
100+ bdr = bdr .Watches (& gatewayv1.Gateway {},
101+ handler .EnqueueRequestsFromMapFunc (r .listGatewayProxiesByGateway ),
102+ )
103+ }
104+
88105 return bdr .
89106 Watches (& corev1.Secret {},
90107 handler .EnqueueRequestsFromMapFunc (r .listGatewayProxiesForSecret ),
@@ -265,3 +282,32 @@ func (r *GatewayProxyController) listGatewayProxiesForSecret(ctx context.Context
265282 indexer .SecretIndexRef : indexer .GenIndexKey (secret .GetNamespace (), secret .GetName ()),
266283 })
267284}
285+
286+ func (r * GatewayProxyController ) listGatewayProxiesForIngressClass (ctx context.Context , object client.Object ) []reconcile.Request {
287+ ingressClass := pkgutils .ConvertToIngressClassV1 (object )
288+
289+ reqs := []reconcile.Request {}
290+ gp , _ := GetGatewayProxyByIngressClass (ctx , r .Client , ingressClass )
291+ if gp != nil {
292+ reqs = append (reqs , reconcile.Request {
293+ NamespacedName : utils .NamespacedName (gp ),
294+ })
295+ }
296+ return reqs
297+ }
298+
299+ func (r * GatewayProxyController ) listGatewayProxiesByGateway (ctx context.Context , object client.Object ) []reconcile.Request {
300+ gateway , ok := object .(* gatewayv1.Gateway )
301+ if ! ok {
302+ r .Log .Error (errors .New ("unexpected object type" ), "failed to convert object to IngressClass" )
303+ return nil
304+ }
305+ reqs := []reconcile.Request {}
306+ gp , _ := GetGatewayProxyByGateway (ctx , r .Client , gateway )
307+ if gp != nil {
308+ reqs = append (reqs , reconcile.Request {
309+ NamespacedName : utils .NamespacedName (gp ),
310+ })
311+ }
312+ return reqs
313+ }
0 commit comments