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

Support multiple route pairs in docker labels #78

Closed
umputun opened this issue May 20, 2021 · 8 comments
Closed

Support multiple route pairs in docker labels #78

umputun opened this issue May 20, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@umputun
Copy link
Owner

umputun commented May 20, 2021

re: #76

In some cases, one container may expose multiple endpoints, for example, public API and some admin API. They can be on different ports and the goal is to allow such functionality to be defined with docker provider (labels?)

I can think of two ways to implement it:

  • add numeric suffix to reproxy.*.N, i.e. reproxy.server.1=example.com, reproxy.dest.1=blah and so on. This may increase the number of labels and could be ugly in extreme cases
  • similar to the first approach but combine the rule in this style of static provider, i.e. reproxy.1=m.example.com,/api/(.*)./someplace/$1,/ping. This is harder to read but will minimize the number of labels

both approaches can be combined too, and the user can choose which one he likes better. The current labels should be supported too as we don't want to break compatibility for no good reason

if anyone has better ideas pls share

@umputun
Copy link
Owner Author

umputun commented May 20, 2021

cc @avowkind

@avowkind
Copy link

Thanks for looking at this.
Here's an example that might illustrate.

  • split the labels into multiple groups.
  • indicate which port each group should use. or assume from the order of the port defs
version: '3.5'
services:
  computer-vision:
    image: pfr-computer-vision:latest
    ports:
      - 14000:14000 <-- port 1
      - 14001:14001  <-- port 2
    labels:
      reproxy.1.ping: '/api/v1/ping'
      reproxy.1.route: "(/api/v1)"
      reproxy.1.dest: "$scheme://$host:$port.1/$path"
      reproxy.1.enabled: true
      reproxy.2.ping: '/api/v2/ping'
      reproxy.2.route: "(/api/v2)"
      reproxy.2.port: 14001
      reproxy.2.dest: $$1
      reproxy.2.enabled: true 

@umputun umputun self-assigned this May 26, 2021
@umputun umputun added enhancement New feature or request and removed discussion labels May 26, 2021
umputun added a commit that referenced this issue May 26, 2021
* support reproxy.N.something labels for docker #78

* lint: suppress false positive

* update linter in ci

* update readme

* add test for failed container parse
@umputun
Copy link
Owner Author

umputun commented May 26, 2021

yeah, this is the format I've implementing except for one thing - I don't see the need in reproxy.N.enabled because this label enables the container for discovery, not the particular route. So, the current reproxy.enabled should be sufficient.

The N should be in [0:9] range, i.e. reproxy.7.server, reproxy.0.port, and so on. Current labels back-compatible and treated internally as reproxy.0.*

Check out the :master image as you have a chance. I have not tested it on the real setups yet but covered with enough unit test, so hopefully, it will work as designed.

pls note - this is not limited to different ports only and reporxy.1.* and reproxy.2.* labels may have the same port or even the default one (the first exposed if nothing defined in reproxy.N.port). I have recently witnessed a complex config with a lot of custom routes mapped for a single container and the same port (service)

@umputun
Copy link
Owner Author

umputun commented May 26, 2021

actually, I just deployed it with multi-routes to one of my boxes and it worked fine. This is the relevant part of the compose:

feed-master:
    image: umputun/feed-master:master
    container_name: feed-master
    hostname: feed-master
    restart: always
    logging: *default_logging
    labels:
      reproxy.server: feedmaster.umputun.com
      reproxy.route: '^/(.*)'
      reproxy.1.route: '^/echo/image.png$$'
      reproxy.1.dest: '/image/echo-msk'
      reproxy.2.route: '^/all-umputun/imgage.png$$'
      reproxy.2.dest: '/image/all-umputun'
      reproxy.3.route: '^/echo$$'
      reproxy.3.dest: '/rss/echo-msk'
      reproxy.4.route: '^/all-umputun$$'
      reproxy.4.dest: '/rss/all-umputun'

    environment:
      - MHOST
      - TELEGRAM_TOKEN=${TELEGRAM_TOKEN}
      - DEBUG=false
      - FM_DB=/srv/var/feed-master.bdb
      - FM_CONF=/srv/etc/fm.yml

@zorion79
Copy link

zorion79 commented May 26, 2021

I'm still waiting for labels port (I'm use docker swarm) and I'll delete Traefik :-)

@umputun
Copy link
Owner Author

umputun commented May 26, 2021

I'm still waiting for labels port (I'm use docker swarm) and I'll delete Traefik :-)

Not sure what is missing with the current reproxy.port, can you provide details?

@zorion79
Copy link

I'm still waiting for labels port (I'm use docker swarm) and I'll delete Traefik :-)

Not sure what is missing with the current reproxy.port, can you provide details?

Sorry. I'm didn't notice this before. I'll have to check this.
Reproxy could not found containers for one service on two docker swarm servers. I'm thought this may fix with the port.

@umputun umputun closed this as completed May 29, 2021
@kuhytitusdlz
Copy link

hi @umputun , please add port/enabled to File provider description, it may be helplfull

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

No branches or pull requests

4 participants