Gateway API objects and attachment
Separate ownership from traffic
Gateway API is a Kubernetes API for describing how traffic reaches applications. GatewayClass identifies a controller implementation; Gateway requests a concrete entry point with listeners; HTTPRoute describes application routing. The infrastructure operator selects a class, the platform team controls the listener, and the application team owns a route. These are recommended responsibilities, enforced only when RBAC and namespace governance are configured. An ordinary Nginx Pod does not reconcile these objects. Gateway Fabric translates the desired objects into a managed Nginx data plane.
Configuration: GatewayClass → Gateway ← HTTPRoute → ServiceTraffic: client → Nginx data plane → backend endpointSelect the implementation
The class below names the documented Gateway Fabric controller identity. It is cluster-scoped; the class name must match the controller configuration and must not collide with another controller. The example is an offline candidate, not an instruction to create cluster-level resources. A controller needs permission and must accept the class before it can manage its Gateways.
apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata: name: bm-gatewayspec: controllerName: gateway.nginx.org/nginx-gateway-controllerRead a listener and its attachment rules
The HTTPS listener requires a certificate Secret in bm-edge51. Its name is catalog; the route must refer to this listener via sectionName and be allowed by the namespace selector and kind. The permitted namespace has the label bm-gateway-access=catalog; control who may alter namespace labels. The route hostname must intersect the listener hostname. An HTTP path match is evaluated after TLS termination; SNI is not a substitute for application authorization. This lab intentionally contains no certificate key.
apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata: name: edge namespace: bm-edge51spec: gatewayClassName: bm-gateway listeners: - name: catalog protocol: HTTPS port: 443 hostname: catalog.example.test tls: mode: Terminate certificateRefs: - name: catalog-tls allowedRoutes: namespaces: from: Selector selector: matchLabels: bm-gateway-access: catalog kinds: - kind: HTTPRouteTrace a route to two backends
The route is owned by bm-app51, points at the named listener in bm-edge51 and matches the /catalog path prefix on the stated host. /catalog/items matches, /catalogue does not. Service ports refer to Service spec.ports.port, not arbitrary Pod ports. The second backend is in another namespace and needs explicit permission from its owner (see lesson 3). The route expresses a 9:1 relative split, not a guarantee of exactly nine responses out of ten.
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: catalog namespace: bm-app51spec: parentRefs: - name: edge namespace: bm-edge51 sectionName: catalog hostnames: [catalog.example.test] rules: - matches: - path: type: PathPrefix value: /catalog backendRefs: - name: catalog-v1 port: 8080 weight: 9 - name: catalog-v2 namespace: bm-backend51 port: 8080 weight: 1Practice and next steps
Practice: Read class.yaml, gateway.yaml, namespaces.yaml and route.yaml. Identify owners, matching host/path and listener. Predict the outcome if the namespace label is removed. Use the staged manual exercise; no live deployment is required.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Gateway API objects and attachment
Assess Gateway API design and operational reasoning.
Which object names the controller implementation?
What selects the named listener?
Which namespace may attach in this fixture?
Which path matches /catalog prefix?
Where is the default certificate Secret referenced here?