HTTPRoute Routing and Validation
HTTPRoute Design (Per App)
Section titled “HTTPRoute Design (Per App)”HTTPRoutes are placed in app namespaces and reference the Gateway in the envoy-gateway namespace via parentRefs.
nginx-proxy (Host-based Routing)
Section titled “nginx-proxy (Host-based Routing)”apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: nginx-proxyspec: parentRefs: - name: platform-gateway namespace: envoy-gateway hostnames: - "internal-app.NODE-IP.nip.io" - "app.NODE-IP.nip.io" rules: - matches: - headers: - name: Host value: internal-app.NODE-IP.nip.io backendRefs: - name: nginx-proxy port: 9090 - matches: - headers: - name: Host value: app.NODE-IP.nip.io backendRefs: - name: nginx-proxy port: 8080pgadmin / rabbitmq
Section titled “pgadmin / rabbitmq”# pgadminapiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: pgadminspec: parentRefs: - name: platform-gateway namespace: envoy-gateway hostnames: - "pgadmin.NODE-IP.nip.io" rules: - backendRefs: - name: pgadmin port: 5050---# rabbitmqapiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: rabbitmqspec: parentRefs: - name: platform-gateway namespace: envoy-gateway hostnames: - "rabbitmq.NODE-IP.nip.io" rules: - backendRefs: - name: rabbitmq port: 15672Full HTTPRoute Mapping
Section titled “Full HTTPRoute Mapping”| HTTPRoute | Hostname | Backend | Port |
|---|---|---|---|
| nginx-proxy | internal-app.NODE-IP.nip.io | nginx-proxy | 9090 |
| nginx-proxy | app.NODE-IP.nip.io | nginx-proxy | 8080 |
| pgadmin | pgadmin.NODE-IP.nip.io | pgadmin | 5050 |
| rabbitmq | rabbitmq.NODE-IP.nip.io | rabbitmq | 15672 |
Using nip.io allows testing IP-based host routing without separate DNS configuration.
NodePort & Service Patch Design
Section titled “NodePort & Service Patch Design”Why targetPort Must Be Specified
Section titled “Why targetPort Must Be Specified”Envoy containers often run as non-root, so they may not bind directly to the same port as Service port (80/443). The actual listen port varies by xDS/version and must be verified inside the Pod using ss -tlnp or similar.
NodePort Fixed Example
Section titled “NodePort Fixed Example”| Name | Service port | nodePort | targetPort |
|---|---|---|---|
| http | 80 | 30080 | 10080 |
| https | 443 | 30443 | 10080 |
If the HTTPS listener uses a separate port (e.g., 10443), the
targetPortfor thehttpsentry must be separated.
JSON Merge Patch Gotcha
Section titled “JSON Merge Patch Gotcha”If you omit port in the EnvoyProxy CR’s spec.ports JSON Merge patch, the API server may treat it as port: 0. When two ports both become 0/TCP, the following error occurs:
duplicate entries for key [port=0, protocol="TCP"]Solution: Always explicitly specify port, targetPort, nodePort, and protocol for each entry.
Deployment and Application
Section titled “Deployment and Application”Application Order
Section titled “Application Order”- Envoy Gateway controller: Helm render + Kustomize apply
- External resources:
GatewayClass→EnvoyProxy→ TLS Secret →Gateway - HTTPRoute: Apply in each app namespace (
parentRefsreferences the Gateway)
Namespace Considerations
Section titled “Namespace Considerations”- Gateway / EnvoyProxy / GatewayClass references are based on
envoy-gateway - Using
kubectl apply -f ... -n other-nsmay cause failures due to namespace mismatch with the object - → Use
kubectl apply -k external/or unify with-n envoy-gateway
Validation Commands
Section titled “Validation Commands”# Gateway statuskubectl get gatewayclass,gateway -n envoy-gateway
# Envoy Proxy (data plane)kubectl get svc -n envoy-gateway -l app.kubernetes.io/name=envoykubectl get ds -n envoy-gateway -l app.kubernetes.io/component=proxy
# HTTPRoute (all namespaces)kubectl get httproute -A
# Endpointskubectl get endpoints -n envoy-gatewayValidation and Testing
Section titled “Validation and Testing”What Was Verified in Normal Scenarios
Section titled “What Was Verified in Normal Scenarios”When DNS/LB sends traffic to NodePort (or its frontend), requests are recorded in the Envoy access log.
Key fields to check in logs:
| Field | Meaning |
|---|---|
:authority | Request Host |
upstream_host | Actual proxied Pod IP:port |
response_code | Upstream response code |
response_code_details | via_upstream = response generated by upstream (not Envoy) |
Additional Observations (nginx proxy path)
Section titled “Additional Observations (nginx proxy path)”When another host connects via nginx-proxy, the upstream may return a 301 redirect. In this case, response_code_details: via_upstream, and if LB/Envoy uses HTTPS while nginx only sees HTTP, X-Forwarded-Proto and similar settings need to be configured on the nginx side.
Listen Address Summary
Section titled “Listen Address Summary”| Segment | Port |
|---|---|
| Client → NodePort | 30080 (HTTP), 30443 (HTTPS) |
| Inside Envoy Pod | targetPort 10080 (may vary by environment) |
Always verify the actual LISTEN port using
ss -tlnpor similar, then adjust manifests accordingly.
Summary
Section titled “Summary”| Item | Result |
|---|---|
| Gateway API-based L7 routing | Host/path routing works correctly via HTTPRoute |
| Cross-namespace routing | Apps can reference Gateway from their own namespace |
| NodePort external exposure | Fixed at 30080/30443, easy LB/firewall integration |
| SecurityPolicy (IP control) | Declarative access control at Gateway level |
| ClientTrafficPolicy | Client IP detection via XFF |
| Coexistence with existing Ingress | Independent operation as separate stack |
Gateway API is the successor standard to Ingress, enabling declarative and structured routing management. Among its implementations, Envoy Gateway’s strength lies in data plane customization through the EnvoyProxy CR. The ability to coexist with existing Ingress while gradually migrating is a significant practical advantage.