Skip to content

Commit 1794b81

Browse files
authored
api: add experimental Gateway API flags (#7970)
* API for Experimental Gateway APIs Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * polish Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
1 parent d39a5a0 commit 1794b81

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

api/v1alpha1/envoygateway_helpers.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ var defaultRuntimeFlags = map[RuntimeFlag]bool{
128128
XDSNameSchemeV2: false,
129129
}
130130

131+
// IsEnabled checks if an experimental Gateway API is enabled in the EnvoyGateway configuration.
132+
func (f *GatewayAPIs) IsEnabled(api GatewayAPI) bool {
133+
if f != nil {
134+
for _, enable := range f.Enabled {
135+
if enable == api {
136+
return true
137+
}
138+
}
139+
}
140+
141+
return false
142+
}
143+
131144
// IsEnabled checks if a runtime flag is enabled in the EnvoyGateway configuration.
132145
func (f *RuntimeFlags) IsEnabled(flag RuntimeFlag) bool {
133146
if f != nil {

api/v1alpha1/envoygateway_types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,36 @@ type EnvoyGatewaySpec struct {
100100
// +optional
101101
ExtensionAPIs *ExtensionAPISettings `json:"extensionApis,omitempty"`
102102

103+
// GatewayAPIs defines feature flags for experimental Gateway API resources.
104+
// These APIs live under the gateway.networking.x-k8s.io group and are opt-in.
105+
//
106+
// +optional
107+
// +notImplementedHide
108+
GatewayAPIs *GatewayAPIs `json:"gatewayAPIs,omitempty"`
109+
103110
// RuntimeFlags defines the runtime flags for Envoy Gateway.
104111
// Unlike ExtensionAPIs, these flags are temporary and will be removed in future releases once the related features are stable.
105112
RuntimeFlags *RuntimeFlags `json:"runtimeFlags,omitempty"`
106113
}
107114

115+
// GatewayAPI defines an experimental Gateway API resource that can be enabled.
116+
// +enum
117+
// +kubebuilder:validation:Enum=XListenerSet;XBackendTrafficPolicy
118+
type GatewayAPI string
119+
120+
const (
121+
// XListenerSet enables the Gateway API XListenerSet resource.
122+
// XListenerSet GatewayAPI = "XListenerSet"
123+
// XBackendTrafficPolicy enables the Gateway API XBackendTrafficPolicy resource.
124+
// XBackendTrafficPolicy GatewayAPI = "XBackendTrafficPolicy"
125+
)
126+
127+
// GatewayAPIs provides a mechanism to opt into experimental Gateway API resources.
128+
// These APIs are experimental today and are subject to change or removal as they mature.
129+
type GatewayAPIs struct {
130+
Enabled []GatewayAPI `json:"enabled,omitempty"`
131+
}
132+
108133
// RuntimeFlag defines a runtime flag used to guard breaking changes or risky experimental features in new Envoy Gateway releases.
109134
// A runtime flag may be enabled or disabled by default and can be toggled through the EnvoyGateway resource.
110135
// +enum

api/v1alpha1/zz_generated.deepcopy.go

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

site/content/en/latest/api/extension_types.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,33 @@ _Appears in:_
22732273
| `controllerName` | _string_ | false | | ControllerName defines the name of the Gateway API controller. If unspecified,<br />defaults to "gateway.envoyproxy.io/gatewayclass-controller". See the following<br />for additional details:<br /> https://gateway-api.sigs.k8s.io/reference/1.4/spec/#gatewayclass |
22742274

22752275

2276+
#### GatewayAPI
2277+
2278+
_Underlying type:_ _string_
2279+
2280+
GatewayAPI defines an experimental Gateway API resource that can be enabled.
2281+
2282+
_Appears in:_
2283+
- [GatewayAPIs](#gatewayapis)
2284+
2285+
2286+
2287+
#### GatewayAPIs
2288+
2289+
2290+
2291+
GatewayAPIs provides a mechanism to opt into experimental Gateway API resources.
2292+
These APIs are experimental today and are subject to change or removal as they mature.
2293+
2294+
_Appears in:_
2295+
- [EnvoyGateway](#envoygateway)
2296+
- [EnvoyGatewaySpec](#envoygatewayspec)
2297+
2298+
| Field | Type | Required | Default | Description |
2299+
| --- | --- | --- | --- | --- |
2300+
| `enabled` | _[GatewayAPI](#gatewayapi) array_ | true | | |
2301+
2302+
22762303
#### GlobalRateLimit
22772304

22782305

0 commit comments

Comments
 (0)