TCPRoute and UDPRoute in Gateway API v1.6: What You Need to Know
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
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: TCPRoute1apiVersion: 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: 60001apiVersion: 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: UDPRouteWhen 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 docs35% off the CKA and other certifications with code OCT26NONCYBER, or 40% off Kubernetes security certs (CKS, KCSA) with OCT26CYBER.
CiliumCon Returns: Scaling eBPF Networking at KubeCon 2026
CiliumCon is back, and it's crucial for anyone involved in Kubernetes networking. With Cilium as the de facto CNI, understanding its eBPF foundation is key to managing workloads at scale. Don't miss out on the insights that could elevate your cloud-native architecture.
OVHcloud Joins CNCF: What This Means for Kubernetes in Europe
The CNCF's new partnership with OVHcloud marks a significant shift for Kubernetes in Europe. With OVHcloud operating thousands of production Kubernetes clusters using Cilium, this collaboration promises enhanced networking and security for multi-tenant environments.
Migrating to ALB: Mastering oauth2-proxy in Kubernetes
Switching from NGINX Ingress to ALB can be tricky, especially when handling oauth2-proxy. Learn how to configure oauth2-proxy to work seamlessly with ALB's OIDC authentication capabilities.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.