Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListenerSet APIs + Generated Clients #3588

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions apis/v1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,40 @@ type GatewaySpec struct {
// +optional
// <gateway:experimental>
BackendTLS *GatewayBackendTLS `json:"backendTLS,omitempty"`

// AllowedListeners defines which ListenerSets can be attached to this Gateway.
// While this feature is experimental, the default value is to allow no ListenerSets.
//
// <gateway:experimental>
//
// +optional
AllowedListeners *[]AllowedListeners `json:"allowedListeners,omitempty"`
}

// AllowedListeners defines which ListenerSets can be attached to this Gateway.
type AllowedListeners struct {
// Namespaces defines which namespaces ListenerSets can be attached to this Gateway.
// While this feature is experimental, the default value is to allow no ListenerSets.
//
// +optional
// +kubebuilder:default={from: None}
Namespaces *ListenerNamespaces `json:"namespaces,omitempty"`
}
Comment on lines +293 to +300
Copy link
Member

@shaneutt shaneutt Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this part of the API, because I think it captures a very important use case for cluster admins: when they want a Gateway to operate more like a classic ingress-controller, in that there's a single LB for routes across many namespaces.

What occurs to me is that we should update the GEP, as it currently states cross-namespace as a "later goal" but it seems like we're already going for it, and I'm very much in favor of this being an immediate goal. Anything I'm missing? (if not, please just feel free to update the GEP to reflect the goal and then consider my comment resolved at your discretion)

Eventually I personally would like to take this a step further: I would like our documentation to be even more clear about a strong intention for this kind of use case as I anticipate it being a very common ask over time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I think that cross-namespace is very important for this GEP and I'd love to see it in the first iteration of the API.


// ListenerNamespaces indicate which namespaces ListenerSets should be selected from.
type ListenerNamespaces struct {
// From indicates where ListenerSets can attach to this Gateway. Possible
// values are:
//
// * Same: Only ListenerSets in the same namespace may be attached to this Gateway.
// * None: Only listeners defined in the Gateway's spec are allowed
//
// While this feature is experimental, the default value None
//
// +optional
// +kubebuilder:default=None
// +kubebuilder:validation:Enum=Same;None
From *FromNamespaces `json:"from,omitempty"`
}

// Listener embodies the concept of a logical endpoint where a Gateway accepts
Expand Down Expand Up @@ -602,21 +636,23 @@ type AllowedRoutes struct {
Kinds []RouteGroupKind `json:"kinds,omitempty"`
}

// FromNamespaces specifies namespace from which Routes may be attached to a
// FromNamespaces specifies namespace from which Routes/ListenerSets may be attached to a
// Gateway.
//
// +kubebuilder:validation:Enum=All;Selector;Same
// +kubebuilder:validation:Enum=All;Selector;Same;None
type FromNamespaces string

const (
// Routes in all namespaces may be attached to this Gateway.
// Routes/ListenerSets in all namespaces may be attached to this Gateway.
NamespacesFromAll FromNamespaces = "All"
// Only Routes in namespaces selected by the selector may be attached to
// Only Routes/ListenerSets in namespaces selected by the selector may be attached to
// this Gateway.
NamespacesFromSelector FromNamespaces = "Selector"
// Only Routes in the same namespace as the Gateway may be attached to this
// Only Routes/ListenerSets in the same namespace as the Gateway may be attached to this
// Gateway.
NamespacesFromSame FromNamespaces = "Same"
// No Routes/ListenerSets may be attached to this Gateway.
NamespacesFromNone FromNamespaces = "None"
)

// RouteNamespaces indicate which namespaces Routes should be selected from.
Expand Down
51 changes: 51 additions & 0 deletions apis/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions apisx/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package apix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package apix
package apisx

24 changes: 24 additions & 0 deletions apisx/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the gateway.networking.k8s-x.io
// API group.
//
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
// +groupName=gateway.networking.k8s-x.io
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// +groupName=gateway.networking.k8s-x.io
// +groupName=gateway.networking.x-k8s.io

// +groupGoName=Experimental
package v1alpha1
Loading