L4Route¶
Overview¶
Function¶
Routes requests based on the layer 4 protocol. When combined with a Gateway listener, this resource forwards connections on the port specified by the listener to a set of backends. L4Route is created based on the experimental TCPRoute/UDPRoute defined by the Gateway API community.
Names¶
Singular name |
Plural name |
Short name |
|---|---|---|
l4route |
l4routes |
— |
API group and version¶
gateway.k8s.f5.com/v1
Scope¶
Namespace
Specification¶
spec¶
Field |
Required |
Default |
Description |
|---|---|---|---|
|
Yes |
— |
List of TCP, UDP, and SCTP matchers and actions. Must contain 1 to 16 items. |
|
No |
— |
Type of layer 4 network protocol this route handles. Must be 1 to 255 characters. |
|
No |
|
Preferred acceleration mode for the Packet Velocity ASIC (PVA). |
|
No |
|
Number of client packets before dynamic re-offloading occurs. Accepted values: 0 to 10. |
|
No |
|
Number of server packets before dynamic re-offloading occurs. Accepted values: 0 to 10. |
|
No |
— |
References the resources (usually a |
spec.parentRefs[]¶
Field |
Required |
Default |
Description |
|---|---|---|---|
|
Yes |
— |
Name of the referent. Must be 1 to 253 characters. |
|
No |
|
Group of the referent. To set the core API group (for example, for a |
|
No |
|
Kind of the referent. Must be 1 to 63 characters. |
|
No |
— |
Namespace of the referent. When you don’t set this, it refers to the local namespace of the route. Must be 1 to 63 characters. |
|
No |
— |
Network port this route targets. The system interprets this based on the type of parent resource. Accepted values: 1 to 65535. |
|
No |
— |
Name of a section within the target resource. For a |
spec.rules[]¶
Field |
Required |
Default |
Description |
|---|---|---|---|
|
No |
— |
Defines the backends where matching requests are sent. When unset or invalid, the system rejects connection attempts to this backend. Connection rejections respect weight. Must contain 1 to 16 items. |
spec.rules[].backendRefs[]¶
Field |
Required |
Default |
Description |
|---|---|---|---|
|
Yes |
— |
Name of the referent. Must be 1 to 253 characters. |
|
No |
|
Group of the referent, for example |
|
No |
|
Kubernetes resource kind of the referent, for example |
|
No |
— |
Namespace of the backend. When you don’t set this, the system infers the local namespace. Must be 1 to 63 characters. |
|
No |
— |
Destination port number for this resource. Required when the referent is a Kubernetes |
|
No |
|
Proportion of requests forwarded to the referenced backend, computed as weight divided by the sum of all weights in this list. Weight isn’t a percentage. Accepted values: 0 to 1000000. |
Update service¶
When a backend service is edited, the configuration of the dataplane does not get automatically updated. You must perform these steps in sequence.
Delete the service.
Modify the yaml file of the service.
Reapply the service.
Note
Perform Custom Resource (CR) operations only when the controller is in a running state.
Example manifests¶
Basic L4Route and Gateway API CRs¶
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: f5-gateway-class
spec:
controllerName: f5.com/f5-bnk-instance-f5-cne-controller
description: F5 BIG-IP Kubernetes Gateway
---
apiVersion: gateway.k8s.f5.com/v1alpha1
kind: GatewaySettings
metadata:
name: gw-settings-app-1
namespace: gateway-infra
spec:
ingressConfig:
defaultListenerNetwork:
ipamRefs:
- name: vip-listener-ipam
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: f5-l4-gateway
namespace: gateway-infra
spec:
infrastructure:
parametersRef:
group: gateway.k8s.f5.com
kind: GatewaySettings
name: gw-settings-app-1
gatewayClassName: f5-gateway-class
listeners:
- name: tcp
protocol: TCP
port: 8000
allowedRoutes:
kinds:
- kind: L4Route
group: gateway.k8s.f5.com
---
apiVersion: gateway.k8s.f5.com/v1
kind: L4Route
metadata:
name: my-l4route
namespace: app-ns
spec:
parentRefs:
- name: f5-l4-gateway
sectionName: tcp
namespace: gateway-infra
rules:
- backendRefs:
- name: l4-greeter-server
port: 80
namespace: app-ns
L4Routes traffic weight distribution CR¶
apiVersion: gateway.k8s.f5.com/v1
kind: L4Route
metadata:
name: l4-app-1
spec:
protocol: TCP
parentRefs:
- name: my-l4-gateway
sectionName: tcp
rules:
- backendRefs:
- name: tcp-testapp-rg-0-f5ing-testapp
port: 8050
weight: 70
- name: tcp-testapp-rg-1-f5ing-testapp
port: 8050
weight: 30