OpsCanary
kubernetesnetworkingPractitioner

TCPRoute and UDPRoute in Gateway API v1.6: What You Need to Know

5 min read Kubernetes BlogAug 3, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

The introduction of TCPRoute and UDPRoute in Gateway API v1.6 is a game changer for Kubernetes networking. By allowing you to route traffic based on protocol and port alone, these resources eliminate the need for Layer 7 awareness, making your configurations cleaner and more efficient. This is particularly useful for services that operate at the transport layer, where application-level routing isn't necessary.

To implement TCPRoute, you start by defining a Gateway with a listener that permits TCPRoute attachments. For example, you can create a Gateway that listens on port 12345 and allows TCPRoute connections. Then, you attach a TCPRoute to that listener, which forwards traffic to a specified backend service. The YAML configuration for this is straightforward, as shown in the examples. Similarly, UDPRoute follows the same pattern, allowing you to route UDP traffic in a comparable manner.

In production, remember that the XBackend API is still experimental. Its behavior may change, so avoid relying on it for critical services until it stabilizes. The v1.6 release deprecated the v1alpha2 versions of these routes, so ensure you're using the latest configurations to avoid compatibility issues.

Key takeaways

  • Utilize TCPRoute to route traffic based on protocol and port without Layer 7 awareness.
  • Define a Gateway with listeners to attach TCPRoute and UDPRoute for efficient traffic management.
  • Be cautious with the experimental XBackend API; its behavior can change unexpectedly.

Why it matters

This update simplifies traffic management in Kubernetes, allowing engineers to focus on core functionality without the overhead of Layer 7 routing complexities. It streamlines configurations, making deployments faster and less error-prone.

Code examples

YAML
1apiVersion: gateway.networking.k8s.io/v1
2kind: Gateway
3metadata:
4  name: example-gateway
5spec:
6  gatewayClassName: example-gateway-class
7  listeners:
8  - name: foo
9    protocol: TCP
10    port: 12345
11    allowedRoutes:
12      kinds:
13      - kind: TCPRoute
YAML
1apiVersion: gateway.networking.k8s.io/v1
2kind: TCPRoute
3metadata:
4  name: tcp-app
5spec:
6  parentRefs:
7  - name: example-gateway
8    sectionName: foo
9  rules:
10  - backendRefs:
11    - name: my-foo-service
12      port: 6000
YAML
1apiVersion: gateway.networking.k8s.io/v1
2kind: Gateway
3metadata:
4  name: example-gateway
5spec:
6  gatewayClassName: example-gateway-class
7  listeners:
8  - name: foo
9    protocol: UDP
10    port: 12345
11    allowedRoutes:
12      kinds:
13      - kind: UDPRoute

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
Better StackSponsor

Unified observability — logs, uptime monitoring, and on-call in one place. Used by 50,000+ engineering teams to ship faster and sleep better.

Try Better Stack free →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.