IngressRouteTCP in Kubernetes for headless service

I think I figured it out.
In my case traefik is a part of k3s.
To add a static configuration for this custom Traefik installation (so this is specifically for my "cattle" fellows only):

  1. Created /var/lib/rancher/k3s/server/manifests/traefik-override.yaml with the following content:
piVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    additionalArguments:
    - "--providers.file.filename=/config/traefik-config.toml"
    - "--entrypoints.mongodb=true"
    ports:
      mongodb:
        port: 27017
        protocol: TCP
  1. Restarted k3s.service
    - "--providers.file.filename=/config/traefik-config.toml" - is for the future dynamic configuration and I haven't test it yet

Rancher Docs: Helm

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
  name: mongo-route
  namespace: mongodb

spec:
  entryPoints:
   - mongodb

  routes:
  - match: HostSNI('*')
    services:
    - name: mongodb-cluster-svc
      port: 27017

Now I see in the traefik dashboard my 'mongodb' entrypoint and a successfully created TCP router and Service with discovered pods behind it.

Unfortunately, my mongo string still doesn't work but this is just another painful MongoDB experience.

2 Likes