Skip to content

Commit eb8379b

Browse files
howardjohnDerekTBrown
authored andcommitted
Initial support for ListenerSet (istio#55595)
* Initial ListenerSet support * lint * gen * rebase * Rebase * rebase * misc fixes
1 parent bdb7541 commit eb8379b

38 files changed

+2658
-144
lines changed

manifests/charts/istio-control/istio-discovery/templates/clusterrole.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ rules:
144144
- apiGroups: ["gateway.networking.x-k8s.io"]
145145
resources:
146146
- xbackendtrafficpolicies/status
147+
- xlistenersets/status
147148
verbs: ["update", "patch"]
148149
- apiGroups: ["gateway.networking.k8s.io"]
149150
resources:

pilot/pkg/config/kube/crdclient/types.gen.go

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pilot/pkg/config/kube/gateway/conditions.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020

2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
k8s "sigs.k8s.io/gateway-api/apis/v1"
23-
k8sbeta "sigs.k8s.io/gateway-api/apis/v1beta1"
2423

2524
"istio.io/istio/pilot/pkg/features"
2625
"istio.io/istio/pilot/pkg/model/kstatus"
2726
"istio.io/istio/pkg/config/schema/gvk"
27+
"istio.io/istio/pkg/kube/controllers"
2828
"istio.io/istio/pkg/maps"
2929
"istio.io/istio/pkg/slices"
3030
"istio.io/istio/pkg/util/sets"
@@ -319,13 +319,13 @@ func setConditions(generation int64, existingConditions []metav1.Condition, cond
319319
return existingConditions
320320
}
321321

322-
func reportListenerCondition(index int, l k8s.Listener, obj *k8sbeta.Gateway,
323-
gs *k8sbeta.GatewayStatus, conditions map[string]*condition,
324-
) {
325-
for index >= len(gs.Listeners) {
326-
gs.Listeners = append(gs.Listeners, k8s.ListenerStatus{})
322+
func reportListenerCondition(index int, l k8s.Listener, obj controllers.Object,
323+
statusListeners []k8s.ListenerStatus, conditions map[string]*condition,
324+
) []k8s.ListenerStatus {
325+
for index >= len(statusListeners) {
326+
statusListeners = append(statusListeners, k8s.ListenerStatus{})
327327
}
328-
cond := gs.Listeners[index].Conditions
328+
cond := statusListeners[index].Conditions
329329
supported, valid := generateSupportedKinds(l)
330330
if !valid {
331331
conditions[string(k8s.ListenerConditionResolvedRefs)] = &condition{
@@ -334,12 +334,13 @@ func reportListenerCondition(index int, l k8s.Listener, obj *k8sbeta.Gateway,
334334
message: "Invalid route kinds",
335335
}
336336
}
337-
gs.Listeners[index] = k8s.ListenerStatus{
337+
statusListeners[index] = k8s.ListenerStatus{
338338
Name: l.Name,
339339
AttachedRoutes: 0, // this will be reported later
340340
SupportedKinds: supported,
341-
Conditions: setConditions(obj.Generation, cond, conditions),
341+
Conditions: setConditions(obj.GetGeneration(), cond, conditions),
342342
}
343+
return statusListeners
343344
}
344345

345346
func generateSupportedKinds(l k8s.Listener) ([]k8s.RouteGroupKind, bool) {

pilot/pkg/config/kube/gateway/controller.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type Inputs struct {
137137
GRPCRoutes krt.Collection[*gatewayv1.GRPCRoute]
138138
TCPRoutes krt.Collection[*gatewayalpha.TCPRoute]
139139
TLSRoutes krt.Collection[*gatewayalpha.TLSRoute]
140+
ListenerSets krt.Collection[*gatewayx.XListenerSet]
140141
ReferenceGrants krt.Collection[*gateway.ReferenceGrant]
141142
BackendTrafficPolicy krt.Collection[*gatewayx.XBackendTrafficPolicy]
142143
BackendTLSPolicies krt.Collection[*gatewayalpha3.BackendTLSPolicy]
@@ -200,12 +201,14 @@ func NewController(
200201
inputs.TLSRoutes = buildClient[*gatewayalpha.TLSRoute](c, kc, gvr.TLSRoute, opts, "informer/TLSRoutes")
201202
inputs.BackendTLSPolicies = buildClient[*gatewayalpha3.BackendTLSPolicy](c, kc, gvr.BackendTLSPolicy, opts, "informer/BackendTLSPolicies")
202203
inputs.BackendTrafficPolicy = buildClient[*gatewayx.XBackendTrafficPolicy](c, kc, gvr.XBackendTrafficPolicy, opts, "informer/XBackendTrafficPolicy")
204+
inputs.ListenerSets = buildClient[*gatewayx.XListenerSet](c, kc, gvr.XListenerSet, opts, "informer/XListenerSet")
203205
} else {
204206
// If disabled, still build a collection but make it always empty
205207
inputs.TCPRoutes = krt.NewStaticCollection[*gatewayalpha.TCPRoute](nil, nil, opts.WithName("disable/TCPRoutes")...)
206208
inputs.TLSRoutes = krt.NewStaticCollection[*gatewayalpha.TLSRoute](nil, nil, opts.WithName("disable/TLSRoutes")...)
207209
inputs.BackendTLSPolicies = krt.NewStaticCollection[*gatewayalpha3.BackendTLSPolicy](nil, nil, opts.WithName("disable/BackendTLSPolicies")...)
208210
inputs.BackendTrafficPolicy = krt.NewStaticCollection[*gatewayx.XBackendTrafficPolicy](nil, nil, opts.WithName("disable/XBackendTrafficPolicy")...)
211+
inputs.ListenerSets = krt.NewStaticCollection[*gatewayx.XListenerSet](nil, nil, opts.WithName("disable/XListenerSet")...)
209212
}
210213

211214
references := NewReferenceSet(
@@ -220,6 +223,19 @@ func NewController(
220223
status.RegisterStatus(c.status, GatewayClassStatus, GetStatus)
221224

222225
ReferenceGrants := BuildReferenceGrants(ReferenceGrantsCollection(inputs.ReferenceGrants, opts))
226+
ListenerSetStatus, ListenerSets := ListenerSetCollection(
227+
inputs.ListenerSets,
228+
inputs.Gateways,
229+
GatewayClasses,
230+
inputs.Namespaces,
231+
ReferenceGrants,
232+
inputs.Secrets,
233+
options.DomainSuffix,
234+
c.gatewayContext,
235+
c.tagWatcher,
236+
opts,
237+
)
238+
status.RegisterStatus(c.status, ListenerSetStatus, GetStatus)
223239

224240
DestinationRules := DestinationRuleCollection(
225241
inputs.BackendTrafficPolicy,
@@ -234,6 +250,7 @@ func NewController(
234250
// Do not register yet.
235251
GatewaysStatus, Gateways := GatewayCollection(
236252
inputs.Gateways,
253+
ListenerSets,
237254
GatewayClasses,
238255
inputs.Namespaces,
239256
ReferenceGrants,
@@ -475,8 +492,8 @@ func (c *Controller) HasSynced() bool {
475492
return true
476493
}
477494

478-
func (c *Controller) SecretAllowed(resourceName string, namespace string) bool {
479-
return c.outputs.ReferenceGrants.SecretAllowed(nil, resourceName, namespace)
495+
func (c *Controller) SecretAllowed(ourKind config.GroupVersionKind, resourceName string, namespace string) bool {
496+
return c.outputs.ReferenceGrants.SecretAllowed(nil, ourKind, resourceName, namespace)
480497
}
481498

482499
func pushXds[T any](xds model.XDSUpdater, f func(T) model.ConfigKey) func(events []krt.Event[T]) {

0 commit comments

Comments
 (0)