Expose Internal Services Using NGINX Kubernetes Gateway API
Scenario
You are working on an aviation platform and need to expose internal services using the Kubernetes NGINX Gateway API.Two backend services already exist in the airspace namespace:
flight-service— serves flight data on port80booking-service— serves booking data on port8080
Your goal is to expose both services externally through a single Gateway using path-based routing under the domain airspace.io.
Task
Create the required Kubernetes Gateway API resources in the airspace namespace:
- A Gateway named
airspace-gatewaythat listens on HTTP port80, usesgatewayClassName: nginx, and is accessible externally via a LoadBalancer - An HTTPRoute named
airspace-routesattached to the Gateway with path-based routing:- Requests to
/flights→flight-serviceon port80 - Requests to
/booking→booking-serviceon port8080
- Requests to
After the Gateway receives an external IP, add it to /etc/hosts on your dev-machine to map airspace.io, then verify both routes respond correctly:
curl http://airspace.io/flights | jq
curl http://airspace.io/booking | jq
⏳ Wait for 1 minute for the NGINX Gateway API to be set up.
🚫 Do not modify the existing Services or Deployments.
After creating the Gateway and HTTPRoute, run kubectl radar on cplane-01, open it on port 9280, and use “Expose HTTP port”, then select the airspace namespace and Topology view (optional).
Hint
A Gateway defines the cluster entry point — set gatewayClassName: nginx, listen on port 80 with HTTP protocol. An HTTPRoute attaches to the Gateway via parentRefs and uses PathPrefix matches to route /flights to flight-service:80 and /booking to booking-service:8080.
Once applied, wait for the external IP and update /etc/hosts:
GATEWAY_IP=$(kubectl get gateway airspace-gateway -n airspace \
-o jsonpath='{.status.addresses[0].value}')
echo "${GATEWAY_IP} airspace.io" | sudo tee -a /etc/hosts