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

rules
array

Yes

—

List of TCP, UDP, and SCTP matchers and actions. Must contain 1 to 16 items.

protocol
string

No

—

Type of layer 4 network protocol this route handles. Must be 1 to 255 characters.

pvaAccelerationMode
string

No

full/assisted

Preferred acceleration mode for the Packet Velocity ASIC (PVA). full/assisted applies partial PVA acceleration when possible, and idle flows can move to software. Accepted values: full/assisted, disabled.

pvaDynamicClientPkts
integer

No

1

Number of client packets before dynamic re-offloading occurs. Accepted values: 0 to 10.

pvaDynamicServerPkts
integer

No

0

Number of server packets before dynamic re-offloading occurs. Accepted values: 0 to 10.

parentRefs
array

No

—

References the resources (usually a Gateway resource) that this route attaches to. The referenced parent resource must allow the attachment. Must contain no more than 32 items.

spec.parentRefs[]

Field

Required

Default

Description

name
string

Yes

—

Name of the referent. Must be 1 to 253 characters.

group
string

No

gateway.networking.k8s.io

Group of the referent. To set the core API group (for example, for a Service referent), set this to an empty string. Must be no more than 253 characters.

kind
string

No

Gateway

Kind of the referent. Must be 1 to 63 characters.

namespace
string

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.

port
integer

No

—

Network port this route targets. The system interprets this based on the type of parent resource. Accepted values: 1 to 65535.

sectionName
string

No

—

Name of a section within the target resource. For a Gateway resource, this is the listener name. For a Service resource, this is the port name. When you don’t set this, the route references the entire resource. Must be 1 to 253 characters.

spec.rules[]

Field

Required

Default

Description

backendRefs
array

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

name
string

Yes

—

Name of the referent. Must be 1 to 253 characters.

group
string

No

""

Group of the referent, for example gateway.networking.k8s.io. When unset or empty, the system infers the core API group. Must be no more than 253 characters.

kind
string

No

Service

Kubernetes resource kind of the referent, for example Service. Must be 1 to 63 characters.

namespace
string

No

—

Namespace of the backend. When you don’t set this, the system infers the local namespace. Must be 1 to 63 characters.

port
integer

No

—

Destination port number for this resource. Required when the referent is a Kubernetes Service resource. Accepted values: 1 to 65535.

weight
integer

No

1

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.

  1. Delete the service.

  2. Modify the yaml file of the service.

  3. 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