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

Backend naming not being set as specified #4284

Closed
amitsaha opened this Issue Dec 10, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@amitsaha
Copy link

amitsaha commented Dec 10, 2018

Do you want to request a feature or report a bug?

Bug

What did you do?

Consider the following docker-compose file:

version: '3'

services:
  reverse-proxy:
    image: traefik # The official Traefik docker image
    command: --api --docker # Enables the web UI and tells Traefik to listen to docker
    ports:
      - "80:80"     # The HTTP port
      - "8080:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
  whoami:
    image: containous/whoami # A container that exposes an API to show its IP address
    labels:
      - "traefik.frontend.rule=Host:whoami.docker.localhost"
      - "traefik.backend=backend1"

  whoami-again:
    image: containous/whoami # A container that exposes an API to show its IP address
    labels:
      - "traefik.frontend.rule=Host:whoami.docker.localhost"
      - "traefik.site1.backend=backendsite1"

Run docker-compose up

Go to http://localhost:8080/api/providers/docker/backends, we will get the three backends that's configured:

{
  "backend-backend1": {
    "servers": {
      "server-traefik-demo-whoami-1-86460ec963c2-f0078ecb386e282a8fc546f06636ff94": {
        "url": "http:\/\/172.18.0.3:80",
        "weight": 1
      }
    },
    "loadBalancer": {
      "method": "wrr"
    }
  },
  "backend-reverse-proxy-traefik-demo": {
    "servers": {
      "server-traefik-demo-reverse-proxy-1-807284c2bf53-a4b9e1129a86189ee88fc1a031f0c65d": {
        "url": "http:\/\/172.18.0.4:80",
        "weight": 1
      }
    },
    "loadBalancer": {
      "method": "wrr"
    }
  },
  "backend-whoami-again-traefik-demo-backendsite1": {
    "servers": {
      "server-traefik-demo-whoami-again-1-36490b790acf-780f230448df16d66397c0c29cebc062": {
        "url": "http:\/\/172.18.0.2:80",
        "weight": 1
      }
    },
    "loadBalancer": {
      "method": "wrr"
    }
  }
}

What did you expect to see?

I expected to see the backend for whoami service to be backend1 and the backend for whoami-again to be backendsite1.

What did you see instead?

Instead the backend for backend1 is set to backend-backend1 and backend for backendsite1 set to
backend-<container-name>-backendsite1

Output of traefik version: (What version of Traefik are you using?)

~\work\traefik-demo> docker run traefik version
Version:      v1.7.5
Codename:     maroilles
Go version:   go1.11.2
Built:        2018-12-03_11:01:00AM
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, ...)?

The above docker-compose.yml should be sufficient.

If applicable, please paste the log output in DEBUG level (--logLevel=DEBUG switch)

Please let me know if this is needed.

@ldez

This comment has been minimized.

Copy link
Member

ldez commented Dec 10, 2018

Hello, it's the expected behavior.

@amitsaha

This comment has been minimized.

Copy link
Author

amitsaha commented Dec 10, 2018

Hello, it's the expected behavior.

Thanks. Is there no way to set the backend name to a defined string? If not, what's the rationale? If you think of a backend (or a segment) as a pool of instances, why not name it exactly the same as the user specified string?

dduportal added a commit to dduportal/traefik that referenced this issue Dec 19, 2018

Docs: rephrase the traefik.backend definition to help on issues as co…
…ntainous#4284

Signed-off-by: Damien DUPORTAL <damien.duportal@gmail.com>
@dduportal

This comment has been minimized.

Copy link
Contributor

dduportal commented Dec 19, 2018

Hi @amitsaha , thanks for your interest in Traefik's project!

The pull request #4317 had been opened to propose a rephrasing about the label traefik.backend.
The goal is to avoid user to think that providing the label would set the full name, because it might be confusing.

What do you think?

About your question, the backend name generation is an internal task, and changing it would be breaking. The provided value to traefik.backend is to discriminate backends from each others.

@amitsaha

This comment has been minimized.

Copy link
Author

amitsaha commented Dec 19, 2018

Thanks @dduportal - I made a comment on the updates for the docker backend docs.

@ldez

This comment has been minimized.

Copy link
Member

ldez commented Dec 20, 2018

Closed by #4317

@ldez ldez closed this Dec 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment