Skip to content

Commit 62c34a0

Browse files
authored
fix: rename listener using its protocol and port (#6544)
* rename listener using its address and port Signed-off-by: Huabing (Robin) Zhao <[email protected]> * rename udp listener using its address and port Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix e2e Signed-off-by: Huabing (Robin) Zhao <[email protected]> * add metadata to listener Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix e2e Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix test Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix test Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix test Signed-off-by: Huabing (Robin) Zhao <[email protected]> * add feature flag for listener name Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove metadata for tcp and udp listeners Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix int Signed-off-by: Huabing (Robin) Zhao <[email protected]> * release notes Signed-off-by: Huabing (Robin) Zhao <[email protected]> * update api Signed-off-by: Huabing (Robin) Zhao <[email protected]> * add validation Signed-off-by: Huabing (Robin) Zhao <[email protected]> * add protocol prefix to listener name Signed-off-by: Huabing (Robin) Zhao <[email protected]> * rename listener using protocol and port Signed-off-by: Huabing (Robin) Zhao <[email protected]> * rename tests Signed-off-by: Huabing (Robin) Zhao <[email protected]> * add host suffix to filterChain name Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix test Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix e2e Signed-off-by: Huabing (Robin) Zhao <[email protected]> * modify listener stat prefix Signed-off-by: Huabing (Robin) Zhao <[email protected]> * rename routeconfig Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix e2e Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix gen Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix gen Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix e2e Signed-off-by: Huabing (Robin) Zhao <[email protected]> * minor change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove duplicated virtual hosts in RouteConfig Signed-off-by: Huabing (Robin) Zhao <[email protected]> * minor change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * split route config on different hosts for HTTPS listeners Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove listener metadata Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove listener metadata Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove external port Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove listener metadata Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove unnecessary change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove unnecessary change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * update test file Signed-off-by: Huabing (Robin) Zhao <[email protected]> * set listener and filter chain names, rollback other names Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix gen Signed-off-by: Huabing (Robin) Zhao <[email protected]> * minor change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * remove unnecessary change Signed-off-by: Huabing (Robin) Zhao <[email protected]> * update the default filter chain name Signed-off-by: Huabing (Robin) Zhao <[email protected]> * address comment Signed-off-by: Huabing (Robin) Zhao <[email protected]> * fix gen Signed-off-by: Huabing (Robin) Zhao <[email protected]> --------- Signed-off-by: Huabing (Robin) Zhao <[email protected]>
1 parent 907b90b commit 62c34a0

File tree

455 files changed

+3109
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

455 files changed

+3109
-134
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ jobs:
102102
- version: v1.33.1
103103
ipFamily: dual # only run dual test on latest version to save time
104104
profile: gateway-namespace-mode
105+
- version: v1.33.1
106+
ipFamily: ipv4
107+
profile: xds-name-scheme-v2
105108
steps:
106109
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
107110
- uses: ./tools/github-actions/setup-deps
@@ -149,6 +152,10 @@ jobs:
149152
- version: v1.33.1
150153
ipFamily: dual # only run dual test on latest version to save time
151154
profile: gateway-namespace-mode
155+
- version: v1.33.1
156+
ipFamily: ipv4
157+
profile: xds-name-scheme-v2
158+
152159
steps:
153160
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
154161
- uses: ./tools/github-actions/setup-deps

api/v1alpha1/envoygateway_helpers.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,32 @@ func (e *EnvoyGateway) GatewayNamespaceMode() bool {
109109
*e.Provider.Kubernetes.Deploy.Type == KubernetesDeployModeTypeGatewayNamespace
110110
}
111111

112+
// defaultRuntimeFlags are the default runtime flags for Envoy Gateway.
113+
var defaultRuntimeFlags = map[RuntimeFlag]bool{
114+
XDSNameSchemeV2: false,
115+
}
116+
117+
// IsEnabled checks if a runtime flag is enabled in the EnvoyGateway configuration.
118+
func (f *RuntimeFlags) IsEnabled(flag RuntimeFlag) bool {
119+
if f != nil {
120+
for _, disable := range f.Disabled {
121+
if disable == flag {
122+
return false
123+
}
124+
}
125+
for _, enable := range f.Enabled {
126+
if enable == flag {
127+
return true
128+
}
129+
}
130+
}
131+
132+
if defaultValue, found := defaultRuntimeFlags[flag]; found {
133+
return defaultValue
134+
}
135+
return false
136+
}
137+
112138
// DefaultLeaderElection returns a new LeaderElection with default configuration parameters.
113139
func DefaultLeaderElection() *LeaderElection {
114140
return &LeaderElection{

api/v1alpha1/envoygateway_types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ type EnvoyGatewaySpec struct {
101101

102102
// RuntimeFlag defines a runtime flag used to guard breaking changes or risky experimental features in new Envoy Gateway releases.
103103
// A runtime flag may be enabled or disabled by default and can be toggled through the EnvoyGateway resource.
104+
// +enum
105+
// +kubebuilder:validation:Enum=XDSNameSchemeV2
104106
type RuntimeFlag string
105107

106108
const (
107-
// UseAddressAsListenerName indicates that the listener name should be derived from the address and port.
108-
UseAddressAsListenerName RuntimeFlag = "UseAddressAsListenerName"
109+
// XDSNameSchemeV2 indicates that the xds name scheme v2 is used.
110+
// * The listener name will be generated using the protocol and port of the listener.
111+
XDSNameSchemeV2 RuntimeFlag = "XDSNameSchemeV2"
109112
)
110113

111114
// RuntimeFlags provide a mechanism to guard breaking changes or risky experimental features in new Envoy Gateway releases.

internal/cmd/egctl/testdata/translate/out/quickstart.all.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ xdsIR:
109109
- path: /dev/stdout
110110
http:
111111
- address: 0.0.0.0
112+
externalPort: 80
112113
hostnames:
113114
- '*'
114115
isHTTP2: false

internal/gatewayapi/listener.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
119119
case gwapiv1.HTTPProtocolType, gwapiv1.HTTPSProtocolType:
120120
irListener := &ir.HTTPListener{
121121
CoreListenerDetails: ir.CoreListenerDetails{
122-
Name: irListenerName(listener),
123-
Address: address,
124-
Port: uint32(containerPort),
125-
Metadata: buildListenerMetadata(listener, gateway),
126-
IPFamily: ipFamily,
122+
Name: irListenerName(listener),
123+
Address: address,
124+
Port: uint32(containerPort),
125+
ExternalPort: uint32(listener.Port),
126+
Metadata: buildListenerMetadata(listener, gateway),
127+
IPFamily: ipFamily,
127128
},
128129
TLS: irTLSConfigs(listener.tlsSecrets...),
129130
Path: ir.PathSettings{
@@ -146,10 +147,11 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
146147
case gwapiv1.TCPProtocolType, gwapiv1.TLSProtocolType:
147148
irListener := &ir.TCPListener{
148149
CoreListenerDetails: ir.CoreListenerDetails{
149-
Name: irListenerName(listener),
150-
Address: address,
151-
Port: uint32(containerPort),
152-
IPFamily: ipFamily,
150+
Name: irListenerName(listener),
151+
Address: address,
152+
Port: uint32(containerPort),
153+
ExternalPort: uint32(listener.Port),
154+
IPFamily: ipFamily,
153155
},
154156

155157
// Gateway is processed firstly, then ClientTrafficPolicy, then xRoute.
@@ -162,9 +164,10 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
162164
case gwapiv1.UDPProtocolType:
163165
irListener := &ir.UDPListener{
164166
CoreListenerDetails: ir.CoreListenerDetails{
165-
Name: irListenerName(listener),
166-
Address: address,
167-
Port: uint32(containerPort),
167+
Name: irListenerName(listener),
168+
Address: address,
169+
Port: uint32(containerPort),
170+
ExternalPort: uint32(listener.Port),
168171
},
169172
}
170173
xdsIR[irKey].UDP = append(xdsIR[irKey].UDP, irListener)

internal/gatewayapi/testdata/accesslog-als-backend.out.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ xdsIR:
215215
protocol: TCP
216216
http:
217217
- address: 0.0.0.0
218+
externalPort: 80
218219
hostnames:
219220
- '*'
220221
isHTTP2: false

internal/gatewayapi/testdata/accesslog-als-grpc.out.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ xdsIR:
117117
protocol: TCP
118118
http:
119119
- address: 0.0.0.0
120+
externalPort: 80
120121
hostnames:
121122
- '*'
122123
isHTTP2: false

internal/gatewayapi/testdata/accesslog.out.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ xdsIR:
141141
protocol: TCP
142142
http:
143143
- address: 0.0.0.0
144+
externalPort: 80
144145
hostnames:
145146
- '*'
146147
isHTTP2: false

internal/gatewayapi/testdata/backend-invalid-feature-disabled.out.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ xdsIR:
173173
protocol: TCP
174174
http:
175175
- address: 0.0.0.0
176+
externalPort: 80
176177
hostnames:
177178
- '*'
178179
isHTTP2: false

internal/gatewayapi/testdata/backend-tls-settings.out.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ xdsIR:
557557
protocol: TCP
558558
http:
559559
- address: 0.0.0.0
560+
externalPort: 80
560561
hostnames:
561562
- '*'
562563
isHTTP2: false

0 commit comments

Comments
 (0)