Skip to main content

IngressRouteTCP

IngressRouteTCP is the CRD implementation of a Traefik TCP router.

Register the IngressRouteTCP kind in the Kubernetes cluster before creating IngressRouteTCP objects.

General

If both HTTP routers and TCP routers listen to the same EntryPoint, the TCP routers will apply before the HTTP routers. If no matching route is found for the TCP routers, then the HTTP routers will take over.

Configuration Example

ingressroute-tcp.yaml
apiVersion: traefik.io/v1alpha1
kind: IngressRouteTCP
metadata:
name: test-tcp
namespace: apps
spec:
entryPoints:
- websecure
routes:
- match: HostSNI(`*`)
priority: 10
services:
- name: foo
port: 8080
nativeLB: true
tls:
secretName: supersecret
options:
name: opt
namespace: apps
passthrough: false

Configuration Options

FieldDescriptionDefaultRequired
entryPointsList of entrypoints namesNo
routesList of routesYes
routes[n].matchDefines the rule of the underlying router""No
routes[n].priorityDefines the priority to disambiguate rules of the same length, for route matching0No
routes[n].middlewares[n].nameDefines the MiddlewareTCP nameNo
routes[n].middlewares[n].namespaceDefines the MiddlewareTCP namespace""No
routes[n].servicesList of Kubernetes service definitions (See below for ExternalName Service setup)No
routes[n].services[n].nameDefines the name of a Kubernetes service""Yes
routes[n].services[n].portDefines the port of a Kubernetes service. This can be a reference to a named port.""No
routes[n].services[n].weightDefines the weight to apply to the server load balancing""No
routes[n].services[n].proxyProtocolDefines the PROXY protocol configuration
routes[n].services[n].proxyProtocol.versionDefines the PROXY protocol version
routes[n].services[n].serversTransportDefines the ServersTransportTCP.
The ServersTransport namespace is assumed to be the Kubernetes service namespace (see ServersTransport reference).
routes[n].services[n].nativeLBControls, when creating the load-balancer, whether the LB's children are directly the pods IPs or if the only child is the Kubernetes Service clusterIP.falseNo
routes[n].services[n].nodePortLBControls, when creating the load-balancer, whether the LB's children are directly the nodes internal IPs using the nodePort when the service type isfalseno
tlsTLS configuration.
Can be an empty value({}):
A self signed is generated in such a case
(or the default certificate is used if it is defined.)
No
tls.secretNameDefines the secret name used to store the certificate (in the IngressRoute namespace)""No
tls.optionsDefines the reference to a TLSOption""No
tls.options.nameDefines the TLSOption name""No
tls.options.namespaceDefines the TLSOption namespace""No
tls.certResolverDefines the reference to a CertResolver""No
tls.domainsList of domains""No
tls.domains[n].mainDefines the main domain name""Yes
tls.domains[n].sansList of SANs (alternative domains)""No
tls.passthroughIf true, delegates the TLS termination to the backendfalseNo

routes.services

ExternalName Service

ExternalName Services are used to reference services that exist off platform, on other clusters, or locally.

Healthcheck

As the healthchech cannot be done using the usual Kubernetes livenessprobe and readinessprobe, the IngressRouteTCP brings an option to check the ExternalName Service health.

Port Definition

Traefik Hub connect to a backend with a domain and a port. However, Kubernetes ExternalName Service can be defined without any port. Accordingly, Traefik supports defining a port in two ways:

  • only on IngressRouteTCP service
  • on both sides, you'll be warned if the ports don't match, and the IngressRouteTCP service port is used

Thus, in case of two sides port definition, Traefik expects a match between ports.

apiVersion: traefik.io/v1alpha1
kind: IngressRouteTCP
metadata:
name: test.route
namespace: apps
spec:
entryPoints:
- foo
routes:
- match: HostSNI(`*`)
kind: Rule
services:
- name: external-svc
port: 80

routes.services.nodePortLB

To avoid creating the server load-balancer with the pods IPs and use Kubernetes Service clusterIP directly, one should set the TCP service NativeLB option to true. By default, NativeLB is false.

apiVersion: traefik.io/v1alpha1
kind: IngressRouteTCP
metadata:
name: test.route
namespace: default
spec:
entryPoints:
- foo
routes:
- match: HostSNI(`*`)
services:
- name: svc
port: 80
# Here, nativeLB instructs to build the servers load balancer with the Kubernetes Service clusterIP only.
nativeLB: true