I know this is an old post, but just in case others find this post and are STILL trying to figure out how to make this work...
So the thing that I was missing until my head was bloody, was the disconnect between the documentation sort of explaining how to create entry points, and the documentation sort of explaining how to specify them in the IngressRouteTCP.
So YMMV of course, I am starting from a k3s install in which Traefik is already installed "by magic", so when setting this up from scratch there might be better ways.
First you need port 3306 to get to the deployment, so we edit the traefik service with kubectl edit service traefik
and add a bit to the ports section:
apiVersion: v1
kind: Service
metadata:
name: traefik
spec:
ports:
- name: mariadb
port: 3306
protocol: TCP
targetPort: mariadb
Then we need the pod to listen up to 3306, so we kubectl edit deployment traefik
, to add both to the ports section to get it to listen, but also the args to actually add the entrypoint (this is the magic part, keep track of the value between entryPoints.
and address-:3306/tcp
:
apiVersion: v1
kind: Deployment
metadata:
name: traefik
spec:
template:
spec:
containers:
- args:
- --entryPoints.mariadb.address=:3306/tcp
ports:
- containerPort: 3306
name: mariadb
protocol: TCP
Now finally, we create the ingress route, we we use that entry point value:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: mariadb
spec:
entryPoints:
- mariadb
routes:
- match: HostSNI(`*`)
services:
- name: mariadb
port: 3306
And boom, from outside the cluster, I am talking to the database!
(I should mention, I have not done a service restart of k3s, it might just wipe out these changes, as they were put in place using a Helm chart and I don't know quite yet if my changes will stick or get wiped out. Fingers crossed, her goes nothing...