How gateway-route works¶
The gateway-route interface is used together with the
gateway-api-integrator charm,
which manages a Kubernetes Gateway API
Gateway resource. The Ingress Configurator charm connects a workload that
requires an ingress relation to the Gateway resource, while also exposing
configuration options - such as hostname and paths - that can be tuned
without modifying either the workload or the gateway-api-integrator charm.
Note
The Gateway API is a Kubernetes-native concept, so the gateway-route
relation should only be used on a Kubernetes substrate. The charm must also be
deployed with --trust so it can manage Kubernetes resources.
Architecture¶
How the backend Service is reached depends on whether the workload has
opened its port in Juju (see Backend service selection).
In the diagrams below, green arrows represent references between Kubernetes resources (traffic/data flow) and blue dashed arrows represent Juju relations. Charm units are shown as rounded nodes, while Kubernetes resources are shown as rectangular nodes.
Port open¶
flowchart LR
CTRL(["Gateway controller"]) --> GW
subgraph Workload["Workload charm"]
WS["K8s: Workload Service"]
end
subgraph IC["ingress-configurator"]
HR["K8s: HTTPRoute(s)"]
end
subgraph GAI["gateway-api-integrator"]
GW["K8s: Gateway"]
SEC["K8s: TLS Secret"]
DNS["K8s: DNS Record"]
end
GW --> HR
HR --> WS
Workload -- "ingress relation" --> IC
IC -- "gateway-route relation" --> GAI
classDef k8s stroke:#2e7d32
classDef juju stroke:#1565c0,stroke-dasharray:5 5
linkStyle 0,1,2 stroke:#2e7d32
linkStyle 3,4 stroke:#1565c0,stroke-dasharray:5 5
Port closed¶
flowchart LR
CTRL(["Gateway controller"]) --> GW
subgraph Workload["Workload charm"]
WS["K8s: Workload Service"]
end
subgraph IC["ingress-configurator"]
HR["K8s: HTTPRoute(s)"]
BS["K8s: Backend Service"]
end
subgraph GAI["gateway-api-integrator"]
GW["K8s: Gateway"]
SEC["K8s: TLS Secret"]
DNS["K8s: DNS Record"]
end
GW --> HR
HR --> BS
BS --> WS
Workload -- "ingress relation" --> IC
IC -- "gateway-route relation" --> GAI
classDef k8s stroke:#2e7d32
classDef juju stroke:#1565c0,stroke-dasharray:5 5
linkStyle 0,1,2,3 stroke:#2e7d32
linkStyle 4,5 stroke:#1565c0,stroke-dasharray:5 5
How HTTPRoute resources are created¶
The Ingress Configurator builds HTTPRoute resources based on the
https_mode received from the provider (see
The gateway-route relation) and the
hostname(s) from its own configuration:
One HTTP route is always created. It covers all hostnames and attaches to every per-hostname HTTP listener on the
Gatewayvia multipleparentRefs. When no hostnames are configured, it falls back to theGateway’s hostname-less HTTP listener.When
https_modeisenabledorenforced, one HTTPS route per hostname is created, each attaching to its corresponding per-hostname HTTPS listener.When
https_modeisenforced, the HTTP route does not forward to the backend. Instead it issues a301HTTPS redirect using aRequestRedirectfilter.
Backend service selection¶
The HTTPRoute forwards traffic to a Kubernetes Service. Which Service is
used depends on whether the workload charm has opened its port in Juju:
Port is open: the workload’s own
Serviceis referenced directly by theHTTPRoute’sbackendRefs.Port is closed: the Ingress Configurator creates a selector-based
Servicethat targets the workload’s pods by theapp.kubernetes.io/namelabel. This allows routing even when the workload has not declared its port to Juju.
All resources created by the Ingress Configurator are labelled with
ingress-configurator.charm.juju.is/managed-by so they can be discovered and
cleaned up on relation departure.
Constraints and limitations¶
Kubernetes only: The Gateway API is a Kubernetes-native concept, so the
gateway-routerelation should only be used on a Kubernetes substrate.HTTP backend protocol only: The
backend-protocolconfiguration option only acceptshttpwithgateway-route. TLS termination happens at theGateway, not at the backend.One route relation at a time: The charm blocks if more than one of
haproxy-route,haproxy-route-tcp, orgateway-routeis related simultaneously.One
gateway-routerelation per ingress-configurator: A singlegateway-api-integratorcan accept multiplegateway-routerelations, but eachingress-configuratorinstance is limited to onegateway-routerelation. To route traffic for multiple workloads through the sameGateway, deploy a separateingress-configuratorfor each workload and relate them all to the samegateway-api-integrator.--trustrequired: The charm needs Kubernetes RBAC permissions to manageHTTPRouteandServiceresources.Same model only: The workload and the Ingress Configurator must run in the same Juju model (Kubernetes namespace); cross-model relations are not supported. When the workload’s port is closed, the selector-based
Serviceonly matches pods in its own namespace. When the port is open, theHTTPRoute’sbackendRefresolves to theHTTPRoute’s own namespace (a cross-namespace reference would require aReferenceGrant, which the charm does not create).