Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple servers behind one service #30

Open
koehnik opened this issue Jan 11, 2024 · 4 comments
Open

multiple servers behind one service #30

koehnik opened this issue Jan 11, 2024 · 4 comments

Comments

@koehnik
Copy link

koehnik commented Jan 11, 2024

Hello there,

got a question which is based on a service which has multiple servers in background.
With the docker deamon it works like charme. But i ran into this issue with traefik-kop.

I want to publish multiple instances behind one router and one service (load balancing in fact).

Here are my labels for the container1 and the same on container2:

 - "traefik.enable=true"
  - "traefik.http.services.test.loadbalancer.server.port=8080"
  - "traefik.docker.network=q-srv"
  - "traefik.http.routers.test.entrypoints=web"
  - "traefik.http.services.test.loadbalancer.server.scheme=http"
  - "traefik.http.routers.test.rule=Host(`test.local`)"

But everytime i start the other container, the IP will bei overwritten on both servers with the latest discovered ip from traefik-kop.
So is it possible to do that?

image
image

Can you give me a hint how to publish both IPs to this service as servers? Would be great :)

@koehnik koehnik changed the title multiple services behind one service multiple servers behind one service Jan 11, 2024
@koehnik
Copy link
Author

koehnik commented Jan 11, 2024

...after browsing a bit at the redis database there is something suspicious:

"traefik/http/services/test/loadBalancer/servers/0/url":
image

"traefik/http/services/test/loadBalancer/servers/1/url":

Both will be rewritten with the same IP Address...
image

@chetan
Copy link
Contributor

chetan commented Jan 11, 2024

@koehnik I'm not sure how a load balanced scenario would work. It looks like it's correctly publishing two services for the same service, which is what you expect. If that's the case, you just need to make one of the services run on a different port. Since both containrs are on the same host and the external traefik instance needs to be able to talk to them both, they must be exposed on different ports. Try binding one of the services on 8081 instead.

@koehnik
Copy link
Author

koehnik commented Jan 11, 2024

@chetan not totally correct. These 2 services run on different hosts. So they got an ipvlan ip-address and these are defined in my compose.yml. And the label "traefik.docker.network=q-srv" points to the right network. So it collects the IP and set the rules.
But unfortunately the traefik/http/services/test/loadBalacer/servers/0/url should be:
10.42.2.100:8080
and traefik/http/services/test/loadBalacer/servers/1/url should be:
10.42.2.101:8080

So i think that there is a bug, which overrides both of them and doesn't seperate them because of 2 containers referencing the same servicename but other IPs.
Is there a option that the "array" got seperate ips?

Addition: If i restart one of the containers, the latest restarted containers IP is set for both.
Thanks in advance! ;)

@chetan
Copy link
Contributor

chetan commented Jan 11, 2024

Ah, I see. In that case, I think it's likely a "last update wins" scenario. traefik-kop is designed to publish distinct services for each container so the fact that it's even sort-of handling this case is a mystery to me. I don't think this will work without some changes but you can try a workaround like adding the kop.bind.ip label explicitly on each host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants