Configure the gateway’s upstream to use an address recognized by mesh service discovery.
On Kubernetes, send traffic to the backend Service address rather than resolving and
load-balancing directly across its Pod IPs. Using the Service address lets the sidecar select endpoints and apply
the policies associated with the service.
Kong Operator can configure the gateway to choose individual backend Pod
addresses. For a mesh backend, enable service-upstream so the gateway uses the Kubernetes
Service’s DNS name instead. For a regular ClusterIP Service, that name resolves to its
ClusterIP. The gateway’s mesh sidecar intercepts that connection, recognizes the
service, and chooses the backend according to mesh routing and load-balancing policies.
To configure this for one backend, add the following annotation to that backend’s Kubernetes
Service. For example, merge this metadata into the existing payments Service in shop;
keep its selector and ports unchanged:
metadata:
name: payments
namespace: shop
annotations:
ingress.kubernetes.io/service-upstream: "true"
Put this on the backend Service, it changes
how the gateway connects to the backend but doesn’t grant access or enable mesh mTLS.
The annotation name remains ingress.kubernetes.io/service-upstream, and
Kong Operator supports it. The per-Service setting keeps the change scoped to one backend.
This ClusterIP configuration is for Services backed by Pods. An ExternalName Service has no
ClusterIP; use the mesh hostname alias described in Use a MeshMultiZoneService as a Gateway API backend.
For cross-zone backends, configure the gateway to use the hostname published for the intended
MeshMultiZoneService or remote
MeshService. The gateway’s mesh sidecar handles the cross-zone path.
Don’t set the gateway’s application upstream to the zone ingress’s raw address: that address
is part of mesh transport, not a replacement for the service destination.
The gateway’s public route and a MeshHTTPRoute have different
jobs. The public route chooses where an external request goes. A MeshHTTPRoute on the gateway
sidecar can then change the mesh backend used for that outbound request. It doesn’t configure
the gateway’s public hostname, certificate, or listener.
A Gateway API HTTPRoute normally references a Kubernetes Service, not a
MeshMultiZoneService. With Kong Operator, you can bridge the two with an
ExternalName Service pointing to the aggregate’s generated mesh hostname. Other Gateway
API implementations may differ in their support for ExternalName backends; check your
controller before using this pattern. See
Kong Operator Gateway API support for
how the Operator manages the Gateway and its routes.
First, inspect the MeshMultiZoneService as seen by the gateway’s zone. Read a generated
hostname from status.addresses[].hostname and its listening port from spec.ports[].port.
Also check status.meshServices to confirm that the aggregate selects the intended services
and zones.
For example, if the published hostname is payments.mesh and the aggregate exposes HTTP on
port 80, create this alias in the gateway’s namespace. Replace the hostname and port with
the values you inspected:
apiVersion: v1
kind: Service
metadata:
name: payments-multizone
namespace: edge
spec:
type: ExternalName
externalName: payments.mesh
ports:
- name: http
port: 80
protocol: TCP
ExternalName is a DNS alias: it doesn’t create a proxy, a ClusterIP or a new mesh identity.
It also doesn’t make the destination a MeshExternalService; this is still an internal
multi-zone mesh destination. Unlike the ignored public gateway Service in
Keep public gateway Services out of mesh discovery,
this Service exists to give the route a backend reference, not to expose the gateway’s Pods.
Assuming a Gateway API Gateway named edge already exists in namespace edge and accepts
this route, reference the alias from an HTTPRoute:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: payments
namespace: edge
spec:
parentRefs:
- name: edge
hostnames:
- payments.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: payments-multizone
port: 80
Here, payments.example.com is the public request hostname, payments-multizone is the
Kubernetes alias, and payments.mesh is the mesh destination hostname. They serve different
purposes. ExternalName doesn’t rewrite the HTTP Host header or configure application TLS;
configure those separately in the gateway if the backend requires them.
The gateway’s DNS resolution must reach mesh DNS and resolve the generated hostname to the
aggregate’s VIP in that zone. Test resolution from the traffic-serving gateway Pod, using the
resolver the gateway process actually uses. An unrelated Pod or a gateway configured to use
a custom external resolver may not resolve the same name. Keep the connection to the VIP
inside outbound interception; don’t exclude the backend port from outbound proxying.
Once the gateway sidecar recognizes the
aggregate’s VIP and port, it uses the normal MeshMultiZoneService connection configuration:
- The gateway sidecar presents its workload certificate. It needs a matching
MeshIdentity
and the trust required to validate the destination.
- The sidecar builds destination identity checks from the SPIFFE identities advertised in
spec.identities of the MeshService resources selected by the aggregate. The alias’s DNS name is
not a workload identity and doesn’t need to appear in a mesh certificate.
- For a remote backend, zone ingress forwards the workload mTLS connection. The destination
proxy authenticates the gateway and evaluates its
MeshTrafficPermission rules.
Allow the gateway’s actual SPIFFE ID on the backend proxies in every zone that can receive
traffic, using the permission pattern shown in Allow the gateway to call the backend. Don’t attach the permission to the ExternalName
Service or try to match the gateway by the alias name. If gateway identities include a zone
in their trust domain or path, allow each intended gateway identity.
For outbound policies, select the gateway with spec.targetRef, then use
spec.to[].targetRef.kind: MeshMultiZoneService and labels from the aggregate itself. Don’t
use the Kubernetes alias name as a MeshService selector. Keep the aggregate’s service
selector narrow and verify its advertised identities and trust before granting access; DNS
resolution alone isn’t evidence of authorization.
Validate both layers: check the HTTPRoute’s Accepted and ResolvedRefs conditions, resolve
the mesh hostname from the gateway, and verify a request reaches an intended backend. Then
exercise another eligible zone and a disallowed caller. A route can be accepted while DNS,
cross-zone reachability, trust or permissions still prevent traffic.