Exposing a service via Kubernetes Gateway API in ambient mode
In Istio ambient mode, the Kubernetes Gateway API serves as the recommended method for configuring ingress traffic routing. You can create Gateway and HTTPRoute resources to deploy a gateway that makes mesh-internal services accessible to external traffic.
Waypoint proxies for Layer 7 routing
To enforce Layer 7 (L7) routing policies — including path-based routing and header matching — deploy a waypoint proxy in the namespace containing your target service. The waypoint proxy handles L7 traffic processing and applies routing rules defined through HTTPRoute and GRPCRoute resources.
In ambient mode, VirtualService resources have limited compatibility and should not be combined with Gateway API configuration. Use Kubernetes Gateway API resources as the standard approach for traffic routing in ambient mode.
Prerequisites
- Alauda Service Mesh v2 Operator is installed.
- The
IstioandIstioCNIresources are configured with the ambient profile. - A
Ztunnelresource has been created. - Confirm Linux kernel compatibility.
- Your Kubernetes cluster supports external load balancers (i.e., Services of type
LoadBalancer).
Procedure
-
Create a namespace called
httpbin: -
Add the
istio-discovery=enabledlabel to thehttpbinnamespace: -
Enable ambient mode for the namespace by applying the dataplane mode label:
-
Deploy the
httpbinsample service: -
Create a file named
httpbin-waypoint.yamlto define a waypoint proxy. ThisGatewayresource uses theistio-waypointgateway class to process L7 traffic for services in the namespace.- The
istio.io/waypoint-for: servicelabel indicates that this waypoint processes traffic for services. The label value determines the type of traffic handled. For details, see Waypoint traffic types (Istio documentation). - Specifies the
istio-waypointgateway class, which deploys a waypoint proxy instead of a standard ingress gateway.
- The
-
Apply the waypoint proxy configuration:
-
Label the
httpbinservice to direct ingress traffic through the waypoint proxy:NOTEThe
istio.io/ingress-use-waypoint=truelabel ensures that traffic arriving from the ingress gateway passes through the waypoint proxy, allowing L7 policies configured on the waypoint to be enforced before traffic reaches thehttpbinservice. -
Associate all services in the namespace with the waypoint proxy by labeling the namespace:
-
Create a file named
httpbin-gw.yamlthat defines a KubernetesGatewayresource. This configures the gateway proxies to accept HTTP traffic on port 80 for the hosthttpbin.example.com.- Specifies the gateway's
Servicetype; defaults toLoadBalancer. - Specifies the virtual hostname that clients use when accessing a mesh service on this port.
- Specifies the gateway's
-
Apply the gateway configuration:
-
Create a file named
httpbin-ingress-hr.yamlthat defines anHTTPRouteresource for the ingress gateway. This resource specifies how traffic is routed from the gateway proxy to thehttpbinservice.- Binds this
HTTPRouteto the KubernetesGatewaycreated in the previous step. - Routes matching traffic to the
httpbinservice on port 8000.
- Binds this
-
Apply the ingress HTTPRoute:
-
Create a file named
httpbin-waypoint-hr.yamlthat defines anHTTPRouteresource for the waypoint proxy. This resource configures path-based routing rules that the waypoint enforces.- Binds this
HTTPRouteto thehttpbinservice. Combined with theistio.io/ingress-use-waypoint=truelabel, this configures the L7 routing rules enforced by the waypoint proxy for traffic destined to the service. - Forwards matching traffic to the
httpbinservice on port 8000.
- Binds this
-
Apply the waypoint HTTPRoute:
NOTEIn this configuration, traffic from the ingress gateway flows through the waypoint proxy because of the
istio.io/ingress-use-waypoint=truelabel on the service. The waypointHTTPRoutethen applies path-based routing policies before the traffic reaches thehttpbinservice. -
Wait for the waypoint proxy to become ready:
Verification
-
Create a namespace for a
curlclient: -
Deploy the
curlclient: -
Add the
istio-discovery=enabledlabel to thecurlnamespace: -
Enable ambient mode for the
curlnamespace: -
Store the name of the
curlpod in a variable: -
From the
curlclient, send a request to the/headersendpoint of thehttpbinapplication through the ingress gatewayService. Set theHostheader tohttpbin.example.comto match the host specified in the KubernetesGatewayandHTTPRouteresources:The response should return an
HTTP/1.1 200 OKstatus, indicating the request was handled successfully.Example output
-
Send a request to an endpoint without a matching URI prefix in the waypoint
HTTPRoute:The response returns
HTTP/1.1 404 Not Found, which is expected because the/getpath has no corresponding prefix match defined in the waypointHTTPRoute.Example output
-
Expose the gateway proxy to traffic outside the cluster by changing the
Servicetype to the defaultLoadBalancer: -
Verify that the
httpbinservice is reachable from outside the cluster using the external hostname or IP address of the gatewayService. Set theINGRESS_HOSTvariable according to your cluster environment.a. Set the
INGRESS_HOSTvariable:b. Set the
INGRESS_PORTvariable:c. Send a
curlrequest to thehttpbinservice using the gateway host:INFOIf
$INGRESS_HOSTis an IPv6 address, enclose it in square brackets when constructing the URL. For example: -
Confirm that the response includes the
HTTP/1.1 200 OKstatus, which indicates the request succeeded.Example output
Cleanup
Remove the resources created in this procedure: