feat: add Gateway support for LRSQL chart#114
Conversation
…alues/template references
|
Ideally this would have a couple of layers/knobs:
I think that the structure surfaced in this article is a good place to start, eg: Then then |
Thanks for meeting with me on this! As discussed, I will avoid supporting the creation of a Gateway resource itself, but use gateway.enabled as the gating mechanism for gateway support and strive for a terse values structure. |
|
One question: any reason for I can't think of a case to configure listeners on one gateway and httproute on another (i.e., different |
While there is never a case where you would want to configure different gateway names/namespaces on httproute and listenerset, I kept them separate because they refer to different resources' parent refs. httpRoute.gatewayName is what the HTTPRoute attaches to, while listenerSet.gatewayName is what the ListenerSet attaches to (in listenerSet mode the HTTPRoute's actual parent is the ListenerSet, not the Gateway). A shared gateway.gatewayName would mean two different things depending on the mode, which felt more misleading than the duplication. And further, the sectionName and port on the httproute refers to the parent gateway and needs to be nested under the httproute, as it is not applicable for a listener set, and I didn't want to have some gateway references at the top level and then others as a subsection to httproute. |
Adds Gateway API support to the lrsql chart via
HTTPRouteand optionalListenerSetresources, alongside cleanup of faulty and misleading ingress values.All Gateway API resources are gated behind a single
gateway.enabledflag.HTTPRoute
When
gateway.enabledis true, anHTTPRouteis rendered that:gateway.httpRoute.gatewayNameby defaultPathPrefix /rule, overridable viagateway.httpRoute.path/gateway.httpRoute.pathTypesectionNameandportto target a specific listener on the parent Gatewayrulesoverride for advanced routing (redirects, rewrites, weighted backends)ListenerSet (optional)
When
gateway.listenerSet.enabledis true, aListenerSetis rendered alongside theHTTPRoute. The ListenerSet:gateway.listenerSet.gatewayName/gateway.listenerSet.gatewayNamespaceallowedRoutes.namespaces.from: SameThis avoids having to declare the hostname in both the Gateway listener and the HTTPRoute, and removes the need for wildcard listener entries on the Gateway.
Two ways to configure listeners:
gateway.listenerSet.https.enabled: true— convenience shorthand that generates a default HTTPS listener on port 443 withmode: Terminate, deriving the cert secret name fromgateway.hostname(e.g.example.com-tls) unless overridden viagateway.listenerSet.https.secretNamegateway.listenerSet.listeners— full override, replacing the auto-generated listener entirelySetting
gateway.httpRoute.gatewayName,gatewayNamespace,sectionName, orportwhilegateway.listenerSet.enabledis true is a render-time error — those fields are unused in that path and the conflict is flagged explicitly.Ingress cleanup
selfSignedparameter — it only gated the TLS stanza rendering but no template existed to generate a self-signed cert, making it dead and misleadingingress.tlscomment to accurately describe what it does (enables the TLS stanza; does not create the secret itself)Testing
All commands run from the repo root (
charts/).HTTPRoute only — default rule, parents to Gateway
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.httpRoute.gatewayName=my-gateway \ --set gateway.httpRoute.gatewayNamespace=infraExpected: HTTPRoute with
parentRefpointing tomy-gatewayininfra,PathPrefix /rule, backendRef totest-lrsql:80.HTTPRoute only — custom path
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.httpRoute.gatewayName=my-gateway \ --set gateway.httpRoute.path=/api \ --set gateway.httpRoute.pathType=ExactExpected: same as above but
path.type: Exact,path.value: /api.HTTPRoute only — sectionName and port
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.httpRoute.gatewayName=my-gateway \ --set gateway.httpRoute.sectionName=https \ --set gateway.httpRoute.port=443Expected:
parentRefincludessectionName: httpsandport: 443.HTTPRoute + ListenerSet — https.enabled (default secret name)
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --show-only templates/listenerset.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.listenerSet.enabled=true \ --set gateway.listenerSet.gatewayName=my-gatewayExpected:
parentRefpoints to the ListenerSet (kind: ListenerSet, same name/namespace)parentRefpoints tomy-gatewaywith no namespace (same-namespace assumed)hostname: "example.com",certificateRefs[0].name: "example.com-tls",allowedRoutes.namespaces.from: SameHTTPRoute + ListenerSet — custom secret name
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --show-only templates/listenerset.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.listenerSet.enabled=true \ --set gateway.listenerSet.gatewayName=my-gateway \ --set gateway.listenerSet.https.secretName=my-custom-certExpected: same as above but
certificateRefs[0].name: "my-custom-cert".HTTPRoute + ListenerSet — full listeners override
Expected: ListenerSet uses the provided listener entry verbatim.
listenerSet.enabled without https.enabled or listeners — should fail
helm template test charts/lrsql \ --show-only templates/listenerset.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.listenerSet.enabled=true \ --set gateway.listenerSet.gatewayName=my-gateway \ --set gateway.listenerSet.https.enabled=falseExpected: render fails with
gateway.listenerSet requires either gateway.listenerSet.https.enabled or a non-empty gateway.listenerSet.listeners.httpRoute gateway fields set with listenerSet.enabled — should fail
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.com \ --set gateway.listenerSet.enabled=true \ --set gateway.listenerSet.gatewayName=my-gateway \ --set gateway.httpRoute.gatewayName=other-gatewayExpected: render fails with
gateway.httpRoute.gatewayName/gatewayNamespace/sectionName/port are ignored when gateway.listenerSet.enabled is true.gateway.httpRoute.gatewayName missing when listenerSet disabled — should fail
helm template test charts/lrsql \ --show-only templates/httproute.yaml \ --set gateway.enabled=true \ --set gateway.hostname=example.comExpected: render fails with
gateway.httpRoute.gatewayName is required when gateway.enabled is true and gateway.listenerSet.enabled is false.