liveBook · Manning

Network listener

As explained in Kubernetes in Action, Second Edition

A UDP listener is a Gateway configuration that accepts UDP traffic on a specified network port.

A network listener is a logical endpoint where a Gateway accepts traffic. Each listener has a name, port, and protocol. For a UDP service, add a listener with `protocol: UDP` on the port clients will contact. section 13.2.2 section 13.5.2

...
spec:
  listeners:
  - name: udp300       #1
    port: 300        #2
    protocol: UDP     #3

This Gateway fragment defines `udp300`, a listener that accepts UDP traffic on port 300. section 13.5.2

The listener accepts traffic, but a UDPRoute is also needed to connect the Gateway to a backend Service. For example, a route can reference `test-gtw` as its parent and send packets to port 3000 of the `test` Service. The client-facing port and backend port need not be the same. section 13.5.2

Test and check support

Run `nc --udp 172.18.255.200 300`, replacing the address with your Gateway’s IP. The test Pod should echo what you type if routing works. At the time described, Istio does not support UDPRoutes, so this test receives no replies; a UDPRoute with no status indicates that no controller processed it. section 13.5.2

Listeners are configured separately for other traffic: HTTP uses an HTTP listener, TCP uses a TCP listener, and pass-through TLS uses a TLS listener. Check a listener’s status when traffic cannot reach a service: it reports conditions, supported route kinds, and the number of attached routes. A listener can also restrict which namespaces may attach routes. section 13.2.3 section 13.6.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Works through listener configuration, route attachment, testing, and status checks, but does not explain UDP packet handling internals.
Examples
Shows a UDP listener on port 300, a UDPRoute to Service port 3000, and a netcat test.
What it assumes
Introduces listeners through Gateway YAML while using an existing GatewayClass and backend Service in the examples.
What you can do after
Operate/configure a UDP listener and route, then check whether the Gateway API implementation processes the UDPRoute.
How it connects
Connects Gateway listeners to UDPRoute, backend Services, listener status, and cross-namespace route permissions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.