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

Use <proto>-<port> for naming service and container ports #3130

Merged
merged 7 commits into from
Apr 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ infraIR:
name: envoy-gateway-system/eg/http
ports:
- containerPort: 10080
name: http
name: http-80
Copy link
Contributor

Choose a reason for hiding this comment

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

like this naming rule

protocol: HTTP
servicePort: 80
metadata:
Expand Down
4 changes: 4 additions & 0 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ func irUDPListenerName(listener *ListenerContext, udpRoute *UDPRouteContext) str
return fmt.Sprintf("%s/%s/%s/%s", listener.gateway.Namespace, listener.gateway.Name, listener.Name, udpRoute.Name)
}

func irListenerPortName(proto ir.ProtocolType, port int32) string {
return strings.ToLower(fmt.Sprintf("%s-%d", proto, port))
}

func irRoutePrefix(route RouteContext) string {
// add a "/" at the end of the prefix to prevent mismatching routes with the
// same prefix. For example, route prefix "/foo/" should not match a route "/foobar".
Expand Down
6 changes: 1 addition & 5 deletions internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,8 @@ func (t *Translator) processInfraIRListener(listener *ListenerContext, infraIR I
proto = ir.UDPProtocolType
}

infraPortName := string(listener.Name)
if t.MergeGateways {
infraPortName = irHTTPListenerName(listener)
}
infraPort := ir.ListenerPort{
Name: infraPortName,
Name: irListenerPortName(proto, servicePort.port),
Protocol: proto,
ServicePort: servicePort.port,
ContainerPort: servicePortToContainerPort(servicePort.port),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ infraIR:
name: envoy-gateway/gateway-btls/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ infraIR:
name: another-namespace/not-same-namespace-gateway/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -520,7 +520,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -535,14 +535,14 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
- address: null
name: envoy-gateway/gateway-2/tcp
ports:
- containerPort: 10053
name: tcp
name: tcp-53
protocol: TCP
servicePort: 53
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -318,7 +318,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -300,7 +300,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -241,7 +241,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -451,7 +451,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -340,7 +340,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -233,7 +233,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -253,7 +253,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -252,7 +252,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ infraIR:
name: default/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ infraIR:
name: default/tcp-gateway/foo
ports:
- containerPort: 8162
name: foo
name: udp-8162
protocol: UDP
servicePort: 8162
- address: null
name: default/tcp-gateway/bar
ports:
- containerPort: 8089
name: bar
name: tcp-8089
protocol: TCP
servicePort: 8089
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ infraIR:
name: default/tcp-gateway/foo
ports:
- containerPort: 8162
name: foo
name: udp-8162
protocol: UDP
servicePort: 8162
- address: null
name: default/tcp-gateway/bar
ports:
- containerPort: 8089
name: bar
name: tcp-8089
protocol: TCP
servicePort: 8089
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand All @@ -237,7 +237,7 @@ infraIR:
name: envoy-gateway/gateway-2/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ infraIR:
name: envoy-gateway/gateway-1/http
ports:
- containerPort: 10080
name: http
name: http-80
protocol: HTTP
servicePort: 80
metadata:
Expand Down
Loading
Loading