infra: add support for merging gateways on to a single EnvoyProxy#1938
infra: add support for merging gateways on to a single EnvoyProxy#1938arkodg merged 17 commits intoenvoyproxy:mainfrom
Conversation
5ce28ba to
152eae3
Compare
4874209 to
1cb2866
Compare
Codecov Report
@@ Coverage Diff @@
## main #1938 +/- ##
==========================================
+ Coverage 65.55% 65.70% +0.15%
==========================================
Files 92 92
Lines 13509 13583 +74
==========================================
+ Hits 8856 8925 +69
- Misses 4107 4111 +4
- Partials 546 547 +1
|
7de9e4c to
ecfb164
Compare
6e6d2e1 to
1f0e697
Compare
internal/gatewayapi/testdata/merge-valid-multiple-gateways.in.yaml
Outdated
Show resolved
Hide resolved
internal/gatewayapi/helpers.go
Outdated
There was a problem hiding this comment.
will irRouteName and irRouteDestinationName collide since now there is nothing unique if the routes attach to multiple gateways resources which now will manifests into a single xds config
or can we reuse ?
There was a problem hiding this comment.
and you then want to do something similar to https://github.com/envoyproxy/gateway/blob/2ecc54da663dc10c9257a61843cd14ba1bb77dcc/internal/provider/utils/utils.go#L33C1-L33C1 in the infra layer side
internal/gatewayapi/helpers.go
Outdated
There was a problem hiding this comment.
lets flip the order of concatenation, similar to irHTTPListenerName ? and we cannot use -, we need to use / , an invalid char as a delimiter
There was a problem hiding this comment.
alright, I thought I could use - as this is mainly used for container ports, but I will change it to / and add this in the infrastructure helper function
|
this is looking pretty good @cnvergence |
|
hey @cnvergence guessing now with this change when |
hey @arkodg, yes, the envoy proxy fleet is redeployed when gatewayclass is referencing mergeGateways: true |
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
49f55b1 to
38dee59
Compare
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com>
38dee59 to
f593c80
Compare
There was a problem hiding this comment.
LGTM, hope this can land in v0.6.0-rc1, tested locally and it works well:
Config:
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: eg
spec:
controllerName: gateway.envoyproxy.io/gatewayclass-controller
parametersRef:
group: gateway.envoyproxy.io
kind: EnvoyProxy
name: custom-proxy-config
namespace: envoy-gateway-system
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
name: custom-proxy-config
namespace: envoy-gateway-system
spec:
mergeGateways: true
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: merged-eg-1
namespace: default
spec:
gatewayClassName: eg
listeners:
- allowedRoutes:
namespaces:
from: Same
name: http
port: 8080
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: merged-eg-2
namespace: default
spec:
gatewayClassName: eg
listeners:
- allowedRoutes:
namespaces:
from: Same
name: http
port: 8081
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: merged-eg-3
namespace: default
spec:
gatewayClassName: eg
listeners:
- allowedRoutes:
namespaces:
from: Same
name: http
port: 8082
protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: hostname1-route
spec:
parentRefs:
- name: merged-eg-1
hostnames:
- "www.example.com"
rules:
- backendRefs:
- group: ""
kind: Service
name: backend
port: 3000
weight: 1
matches:
- path:
type: PathPrefix
value: /example
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: hostname2-route
spec:
parentRefs:
- name: merged-eg-2
hostnames:
- "www.example2.com"
rules:
- backendRefs:
- group: ""
kind: Service
name: backend
port: 3000
weight: 1
matches:
- path:
type: PathPrefix
value: /example2
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: hostname3-route
spec:
parentRefs:
- name: merged-eg-3
hostnames:
- "www.example3.com"
rules:
- backendRefs:
- group: ""
kind: Service
name: backend
port: 3000
weight: 1
matches:
- path:
type: PathPrefix
value: /example3
Result:
❯ kg gateway -A
NAMESPACE NAME CLASS ADDRESS PROGRAMMED AGE
default merged-eg-1 eg 172.18.255.200 True 12m
default merged-eg-2 eg 172.18.255.200 True 12m
default merged-eg-3 eg 172.18.255.200 True 12m
❯ kg httproute -A
NAMESPACE NAME HOSTNAMES AGE
default hostname1-route ["www.example.com"] 27s
default hostname2-route ["www.example2.com"] 27s
default hostname3-route ["www.example3.com"] 27s
❯ kg svc -n envoy-gateway-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
envoy-eg-d8c59e83 LoadBalancer 10.96.161.114 172.18.255.200 8080:31539/TCP,8081:30783/TCP,8082:31013/TCP 12m
envoy-gateway ClusterIP 10.96.116.219 <none> 18000/TCP,18001/TCP 14m
envoy-gateway-metrics-service ClusterIP 10.96.69.160 <none> 8443/TCP 14m
❯ kg pod -n envoy-gateway-system
NAME READY STATUS RESTARTS AGE
envoy-eg-d8c59e83-68fdf67bc9-pgb2v 1/1 Running 0 95s
envoy-gateway-6f557cc687-h8nxh 2/2 Running 0 14mMaybe we need an e2e test for this as a follow-up, and also a user-guide docs.
| resourceName := strings.ReplaceAll(name, "/", "-") | ||
| listenerName := string(resourceName[2]) | ||
|
|
||
| return fmt.Sprintf("%s-%s", listenerName, hashedName[0:14-len(listenerName)]) |
There was a problem hiding this comment.
this is going to be prone to collisions, id recommend hardcoding this to 7 chars of the listener and 8 chars of the hash.
There was a problem hiding this comment.
Yeah, probably it makes more sense, I don't like it either
Initially didn't want to make the listener name that short, I will change it like you proposed in the follow-up
| if port.Protocol == ir.UDPProtocolType { | ||
| protocol = corev1.ProtocolUDP | ||
| } | ||
| // Listeners on merged gateways will have a port name {GatewayNamespace}/{GatewayName}/{ListenerName}. |
There was a problem hiding this comment.
doesnt this need to be hashed to ensure length is under 15 ?
There was a problem hiding this comment.
AFAIK, Service port names apply under standard DNS label names, then it should be fine
There was a problem hiding this comment.
that means the length is 63 ? but im guessing the individual max length of GatewayNamespace , GatewayName & ListenerName is 63 so this need to be trimmed
There was a problem hiding this comment.
That should be trimmed as well, let's just reuse ExpectedResourceHashedName func for it
arkodg
left a comment
There was a problem hiding this comment.
LGTM @cnvergence, thanks for adding this feature
there are a couple of comments mainly around hashed names of container ports that can be addressed in a follow up PR
@tamalsaha can you also help test this feature out
|
Thanks! Does this support cross namespace gateway merge? |
|
@tamalsaha yes it should |
What type of PR is this?
What this PR does / why we need it:
all Gateway Listeners
Which issue(s) this PR fixes:
Fixes: