Skip to content

Commit 37c5380

Browse files
committed
feat: support ir metadata to tcproute/udproute
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
1 parent 26025c6 commit 37c5380

File tree

54 files changed

+484
-2
lines changed

Some content is hidden

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

54 files changed

+484
-2
lines changed

internal/gatewayapi/listener.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
151151
Address: address,
152152
Port: uint32(containerPort),
153153
ExternalPort: uint32(listener.Port),
154+
Metadata: buildListenerMetadata(listener, gateway),
154155
IPFamily: ipFamily,
155156
},
156157

@@ -168,6 +169,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource
168169
Address: address,
169170
Port: uint32(containerPort),
170171
ExternalPort: uint32(listener.Port),
172+
Metadata: buildListenerMetadata(listener, gateway),
171173
},
172174
}
173175
xdsIR[irKey].UDP = append(xdsIR[irKey].UDP, irListener)

internal/gatewayapi/route.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,8 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
11721172
if irListener != nil {
11731173
irRoute := &ir.UDPRoute{
11741174
Name: irUDPRouteName(udpRoute),
1175+
// udpRoute Must have a single rule, so can use index 0.
1176+
Metadata: buildResourceMetadata(udpRoute, udpRoute.Spec.Rules[0].Name),
11751177
Destination: &ir.RouteDestination{
11761178
Name: destName,
11771179
Settings: destSettings,
@@ -1322,6 +1324,8 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
13221324
if irListener != nil {
13231325
irRoute := &ir.TCPRoute{
13241326
Name: irTCPRouteName(tcpRoute),
1327+
// tcpRoute Must have a single rule, so can use index 0.
1328+
Metadata: buildResourceMetadata(tcpRoute, tcpRoute.Spec.Rules[0].Name),
13251329
Destination: &ir.RouteDestination{
13261330
Name: destName,
13271331
Settings: destSettings,

internal/gatewayapi/testdata/backendtrafficpolicy-status-conditions.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,5 +680,10 @@ xdsIR:
680680
tcp:
681681
- address: 0.0.0.0
682682
externalPort: 53
683+
metadata:
684+
kind: Gateway
685+
name: gateway-2
686+
namespace: envoy-gateway
687+
sectionName: tcp
683688
name: envoy-gateway/gateway-2/tcp
684689
port: 10053

internal/gatewayapi/testdata/backendtrafficpolicy-with-tcp-udp-listeners-apply-on-gateway.out.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ xdsIR:
259259
tcp:
260260
- address: 0.0.0.0
261261
externalPort: 8089
262+
metadata:
263+
kind: Gateway
264+
name: tcp-gateway
265+
namespace: default
266+
sectionName: bar
262267
name: default/tcp-gateway/bar
263268
port: 8089
264269
routes:
@@ -312,6 +317,10 @@ xdsIR:
312317
loadBalancer:
313318
consistentHash:
314319
sourceIP: true
320+
metadata:
321+
kind: TCPRoute
322+
name: tls-app-1
323+
namespace: default
315324
name: tcproute/default/tls-app-1
316325
proxyProtocol:
317326
version: V2
@@ -328,6 +337,11 @@ xdsIR:
328337
udp:
329338
- address: 0.0.0.0
330339
externalPort: 8162
340+
metadata:
341+
kind: Gateway
342+
name: tcp-gateway
343+
namespace: default
344+
sectionName: foo
331345
name: default/tcp-gateway/foo
332346
port: 8162
333347
route:
@@ -352,4 +366,8 @@ xdsIR:
352366
loadBalancer:
353367
consistentHash:
354368
sourceIP: true
369+
metadata:
370+
kind: UDPRoute
371+
name: udp-app-1
372+
namespace: default
355373
name: udproute/default/udp-app-1

internal/gatewayapi/testdata/backendtrafficpolicy-with-tcp-udp-listeners-apply-on-route.out.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ xdsIR:
332332
tcp:
333333
- address: 0.0.0.0
334334
externalPort: 8089
335+
metadata:
336+
kind: Gateway
337+
name: tcp-gateway
338+
namespace: default
339+
sectionName: bar
335340
name: default/tcp-gateway/bar
336341
port: 8089
337342
routes:
@@ -385,6 +390,10 @@ xdsIR:
385390
loadBalancer:
386391
consistentHash:
387392
sourceIP: true
393+
metadata:
394+
kind: TCPRoute
395+
name: tcp-app-1
396+
namespace: default
388397
name: tcproute/default/tcp-app-1
389398
proxyProtocol:
390399
version: V2
@@ -401,6 +410,11 @@ xdsIR:
401410
udp:
402411
- address: 0.0.0.0
403412
externalPort: 8162
413+
metadata:
414+
kind: Gateway
415+
name: tcp-gateway
416+
namespace: default
417+
sectionName: foo
404418
name: default/tcp-gateway/foo
405419
port: 8162
406420
route:
@@ -425,4 +439,8 @@ xdsIR:
425439
loadBalancer:
426440
consistentHash:
427441
sourceIP: true
442+
metadata:
443+
kind: UDPRoute
444+
name: udp-app-1
445+
namespace: default
428446
name: udproute/default/udp-app-1

internal/gatewayapi/testdata/clienttrafficpolicy-for-tcp-listeners.out.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ xdsIR:
216216
closeDelay: 10s
217217
value: 3
218218
externalPort: 443
219+
metadata:
220+
kind: Gateway
221+
name: gateway-1
222+
namespace: envoy-gateway
223+
sectionName: tls-1
219224
name: envoy-gateway/gateway-1/tls-1
220225
port: 10443
221226
proxyProtocol: {}
@@ -238,6 +243,10 @@ xdsIR:
238243
name: tcproute/default/tcproute-1/rule/-1/backend/0
239244
protocol: TCP
240245
weight: 1
246+
metadata:
247+
kind: TCPRoute
248+
name: tcproute-1
249+
namespace: default
241250
name: tcproute/default/tcproute-1
242251
tls:
243252
terminate:
@@ -288,6 +297,11 @@ xdsIR:
288297
closeDelay: 10s
289298
value: 3
290299
externalPort: 8080
300+
metadata:
301+
kind: Gateway
302+
name: gateway-1
303+
namespace: envoy-gateway
304+
sectionName: tcp-1
291305
name: envoy-gateway/gateway-1/tcp-1
292306
port: 8080
293307
proxyProtocol: {}
@@ -310,6 +324,10 @@ xdsIR:
310324
name: tcproute/default/tcproute-1/rule/-1/backend/0
311325
protocol: TCP
312326
weight: 1
327+
metadata:
328+
kind: TCPRoute
329+
name: tcproute-1
330+
namespace: default
313331
name: tcproute/default/tcproute-1
314332
tcpKeepalive:
315333
idleTime: 1200

internal/gatewayapi/testdata/clienttrafficpolicy-invalid-settings.out.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ xdsIR:
957957
tcp:
958958
- address: 0.0.0.0
959959
externalPort: 8443
960+
metadata:
961+
kind: Gateway
962+
name: gateway-1
963+
namespace: default
964+
sectionName: tcp-1
960965
name: default/gateway-1/tcp-1
961966
port: 8443
962967
tls:
@@ -969,6 +974,11 @@ xdsIR:
969974
minVersion: "1.2"
970975
- address: 0.0.0.0
971976
externalPort: 5000
977+
metadata:
978+
kind: Gateway
979+
name: gateway-1
980+
namespace: default
981+
sectionName: tcp-2
972982
name: default/gateway-1/tcp-2
973983
port: 5000
974984
routes:
@@ -990,6 +1000,10 @@ xdsIR:
9901000
name: tcproute/default/tcp-route-1/rule/-1/backend/0
9911001
protocol: TCP
9921002
weight: 1
1003+
metadata:
1004+
kind: TCPRoute
1005+
name: tcp-route-1
1006+
namespace: default
9931007
name: tcproute/default/tcp-route-1
9941008
default/gateway-2:
9951009
accessLog:
@@ -1050,6 +1064,11 @@ xdsIR:
10501064
tcp:
10511065
- address: 0.0.0.0
10521066
externalPort: 8443
1067+
metadata:
1068+
kind: Gateway
1069+
name: gateway-2
1070+
namespace: default
1071+
sectionName: tcp-1
10531072
name: default/gateway-2/tcp-1
10541073
port: 8443
10551074
tls:
@@ -1062,6 +1081,11 @@ xdsIR:
10621081
minVersion: "1.2"
10631082
- address: 0.0.0.0
10641083
externalPort: 5000
1084+
metadata:
1085+
kind: Gateway
1086+
name: gateway-2
1087+
namespace: default
1088+
sectionName: tcp-2
10651089
name: default/gateway-2/tcp-2
10661090
port: 5000
10671091
default/gateway-3:
@@ -1133,6 +1157,11 @@ xdsIR:
11331157
tcp:
11341158
- address: 0.0.0.0
11351159
externalPort: 8443
1160+
metadata:
1161+
kind: Gateway
1162+
name: gateway-3
1163+
namespace: default
1164+
sectionName: tcp-1
11361165
name: default/gateway-3/tcp-1
11371166
port: 8443
11381167
tls:
@@ -1145,5 +1174,10 @@ xdsIR:
11451174
minVersion: "1.2"
11461175
- address: 0.0.0.0
11471176
externalPort: 5000
1177+
metadata:
1178+
kind: Gateway
1179+
name: gateway-3
1180+
namespace: default
1181+
sectionName: tcp-2
11481182
name: default/gateway-3/tcp-2
11491183
port: 5000

internal/gatewayapi/testdata/clienttrafficpolicy-mtls-client-verification.out.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ xdsIR:
640640
tcp:
641641
- address: 0.0.0.0
642642
externalPort: 6443
643+
metadata:
644+
kind: Gateway
645+
name: gateway-3
646+
namespace: envoy-gateway
647+
sectionName: tls-1
643648
name: envoy-gateway/gateway-3/tls-1
644649
port: 6443
645650
routes:
@@ -649,6 +654,10 @@ xdsIR:
649654
name: tcproute-1
650655
namespace: envoy-gateway
651656
name: tcproute/envoy-gateway/tcproute-1/rule/-1
657+
metadata:
658+
kind: TCPRoute
659+
name: tcproute-1
660+
namespace: envoy-gateway
652661
name: tcproute/envoy-gateway/tcproute-1
653662
tls:
654663
terminate:

internal/gatewayapi/testdata/clienttrafficpolicy-proxyprotocol-legacy-mixed.out.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ xdsIR:
300300
tcp:
301301
- address: 0.0.0.0
302302
externalPort: 9090
303+
metadata:
304+
kind: Gateway
305+
name: gateway-legacy-only
306+
namespace: envoy-gateway
307+
sectionName: tcp-1
303308
name: envoy-gateway/gateway-legacy-only/tcp-1
304309
port: 9090
305310
proxyProtocol: {}
@@ -310,6 +315,10 @@ xdsIR:
310315
name: tcproute-1
311316
namespace: envoy-gateway
312317
name: tcproute/envoy-gateway/tcproute-1/rule/-1
318+
metadata:
319+
kind: TCPRoute
320+
name: tcproute-1
321+
namespace: envoy-gateway
313322
name: tcproute/envoy-gateway/tcproute-1
314323
envoy-gateway/gateway-new-api-only:
315324
accessLog:

internal/gatewayapi/testdata/clienttrafficpolicy-status-conditions.out.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ xdsIR:
566566
tcp:
567567
- address: 0.0.0.0
568568
externalPort: 53
569+
metadata:
570+
kind: Gateway
571+
name: gateway-2
572+
namespace: envoy-gateway
573+
sectionName: tcp
569574
name: envoy-gateway/gateway-2/tcp
570575
port: 10053
571576
envoy-gateway/gateway-3:

0 commit comments

Comments
 (0)