jittering / traefik-kop

A dynamic docker->redis->traefik discovery agent
MIT License
179 stars 13 forks source link

setting port for tcp service does not work #16

Closed dorianim closed 1 year ago

dorianim commented 1 year ago

Hey :)

I have this configuration

version: "3"

services:
  gitea:
    image: gitea/gitea
    ports:
      - "20080:3000"
      - "20022:22"
    labels:
      traefik.enable: true
      traefik.http.routers.gitea.rule: "Host(`git.domain`)"
      traefik.http.routers.gitea.entrypoints: webs
      traefik.http.routers.gitea.service: gitea@redis
      traefik.http.services.gitea.loadbalancer.server.port: 20080

      traefik.tcp.routers.gitea-ssh.rule: "HostSNI(`*`)"
      traefik.tcp.routers.gitea-ssh.entrypoints: ssh
      traefik.tcp.routers.gitea-ssh.service: gitea-ssh@redis
      traefik.tcp.services.gitea-ssh.loadbalancer.server.port: 20022

The port of the gitea-ssh service is not detected correctly: image

And this is the log:

traefik-kop-traefik-kop-1  | time="2022-09-28T12:37:14Z" level=warning msg="found more than one host-port binding for container '/gitea-gitea-1' (20022:22, 20080:3000)" service-type=tcp service=gitea-ssh@docker
chetan commented 1 year ago

@dorianim looks like a good test case for mixing http & tcp ports. Let me see if I can reproduce the issue.

chetan commented 1 year ago

Not entirely sure if it's a traefik bug or mine, but it looks like traefik is ignoring the server port label for tcp services for some reason. Either way, I fixed it on my end. Pushed a tag 0.12.2-next-amd64 containing the fix. You can see the arm tags on the packages page if you need those instead.

Let me know if that works for you.

dorianim commented 1 year ago

Thanks for your work! Didn't fix it unfortunately. I still get the log:

level=warning msg="found more than one host-port binding for container '/gitea-gitea-1' (20022:22, 20080:3000)" service=gitea-ssh@docker service-type=tcp
level=warning msg="found more than one host-port binding for container '/gitea-gitea-1' (20022:22, 20080:3000)" service=gitea@docker service-type=http
chetan commented 1 year ago

Can you try removing the @redis from the router service name? Not sure if it matters, but I removed it on my end

dorianim commented 1 year ago

tried it, still not working.

chetan commented 1 year ago

@dorianim strange, I just tested with the docker image and it looks like something was wrong with that build. I just pushed a new image which is working for me. Give it another shot (docker pull first) when you have a chance.

Scratch that, I do know what happened -- I had multiple builds from different branches using the same snapshot tag. Will need to fix that for the future.

dorianim commented 1 year ago

Should I do something now, or do I just wait for you to fix the image conflict?

chetan commented 1 year ago

@dorianim sorry, try this image: ghcr.io/jittering/traefik-kop:0.12.2-next-22aaa3b-amd64

dorianim commented 1 year ago

Yayy, it works :D Thanks, man!

chetan commented 1 year ago

Releasing v0.13 shortly