CKAD field manual
k8s Gateway API YAML example
Ingress mixes listener and routing. Gateway API splits them. The GatewayClass must already exist.
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web
namespace: app
spec:
gatewayClassName: nginx
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: web
namespace: app
spec:
parentRefs:
- name: web
hostnames:
- web.example
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: web
port: 80
Fields
- gatewayClassName
- Picks the controller. Same idea as ingressClassName. No class → nothing listens.
- parentRefs
- Which Gateway this route attaches to. name, optional namespace and sectionName.
- backendRefs
- The Service. port is required. weight is for a canary split.
- PathPrefix
- type: PathPrefix, value: /api. Not pathType — that is Ingress.
- allowedRoutes
- from: Same is the usual exam answer. All lets other namespaces attach.
Watch
- apiVersion is gateway.networking.k8s.io/v1. Not networking.k8s.io — that is Ingress.
- HTTPRoute uses type: PathPrefix, not pathType. backendRefs[].port is required.
- The GatewayClass must exist. allowedRoutes.from: Same unless the question says otherwise.
Official docs Gateway API HTTPRoute