Gateway API expresses how traffic reaches applications in a Kubernetes cluster. Compared with an ingress resource, it separates infrastructure configuration from application routing and supports traffic management at layers 4 and 7. It can address traffic entering the cluster and traffic between workloads across namespaces. section 6.7
For a routing task, identify which resource belongs to each responsibility:
- GatewayClass is cluster-scoped. An infrastructure provider defines the controller and underlying infrastructure, such as an external load balancer. section 6.7
- Gateway configures operational details such as listeners, ports, protocols, and TLS certificates. A cluster operator manages it. section 6.7
- A Route defines application-level routing. An application developer can use HTTPRoute for HTTP traffic or another route type, such as TCPRoute. section 6.7
Route a hostname to an application
Apply three gateway.networking.k8s.io/v1 resources with kubectl. Set GatewayClass.spec.controllerName to example.com/gateway-controller. Create a Gateway in the default namespace with gatewayClassName pointing to that class and an HTTP listener on port 80. Then create an HTTPRoute whose parentRefs names the Gateway, whose hostname is www.example.com, and whose PathPrefix / rule sends traffic to the nginx backend on port 8080. section 6.7
$ cat <<EOF | kubectl apply -f -
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-httproute
spec:
parentRefs:
- name: example-gateway
hostnames:
- "www.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: nginx
port: 8080
$ kubectl get httproute
NAME HOSTNAMES AGE
example-httproute ["www.example.com"] 20s
The HTTPRoute manifest shows the parent reference, hostname, path match, and backend reference together. The accompanying kubectl get httproute output verifies that the route appears with its configured hostname; it does not demonstrate that traffic reaches the backend. section 6.7
For CKA practice, know how the three resources fit together and how they differ from a single ingress resource. Gateway API uses custom resource definitions (CRDs); the stated exam emphasis is configuring the objects rather than necessarily installing the API. section 6.7 section 9.3.5


