Skip to content

Adding BTP support for TCPRoute #2880

@jakelevirne

Description

@jakelevirne

Description:
I'd like to apply a BackendTrafficPolicy to to a TCPRoute. The use case is for load balancing traffic to an MQTT broker (VerneMQ) which is run as a Service in my cluster backed by a StatefulSet with 3 replicas. I'm running a bare metal K8s cluster (microk8s) on Raspberry Pi (arm64) nodes.

From the VerneMQ docs, the recommended approach is to use an ingress controller or external load balancer that can route TCP traffic, load balance based on source ip hashing, and provide TLS termination.

I wanted to try envoy gateway to see if it could fit the bill. But from a Slack convo with @arkodg it seems like BackendTrafficPolicy does not yet apply to TCPRoutes. I tried targeting the policy to the Gateway and then to the TCPRoute but neither seemed to work.

[optional Relevant Links:]
Gateway:

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: vernemq-gateway
  namespace: vernemq
spec:
  gatewayClassName: envoy-gateway
  listeners:
  - name: vernemq-listener
    protocol: TCP
    port: 1883
    allowedRoutes:
      kinds:
      - kind: TCPRoute

TCPRoute:

apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
  name: vernemq-route
  namespace: vernemq
spec:
  parentRefs:
  - name: vernemq-gateway
    namespace: vernemq
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: my-vernemq
      port: 1883

BackendTrafficPolicy:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: vernemq-backend-traffic-policy
  namespace: vernemq
spec:
# targetRef:
#    group: gateway.networking.k8s.io
#    kind: Gateway
#    name: vernemq-gateway
#    namespace: vernemq
  targetRef:
    group: gateway.networking.k8s.io
    kind: TCPRoute
    name: vernemq-route
    namespace: vernemq
  loadBalancer:
    type: ConsistentHash
    consistentHash:
      type: SourceIP

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions