I have an instance of RocketChat and I am trying to add stickness to it.
In the docker-compose.yml I have the following labels to my rocketchat service:
- "traefik.enable=true"
- "traefik.http.routers.rocketchat.entrypoints=websecure"
- "traefik.http.routers.rocketchat.tls=true"
- "traefik.http.routers.rocketchat.rule=Host(`salas.jfce.jus.br`)"
- "traefik.docker.network=traefik"
- "traefik.http.services.rocketchat.loadbalancer.server.port=3000"
# - "traefik.http.services.rocketchat.loadbalancer.stickiness=true"
- "traefik.http.services.rocketchat.loadbalancer.healthcheck.path=/api/info"
- "traefik.http.services.rocketchat.loadbalancer.healthcheck.interval=5s"
If I uncomment the line traefik.http.services.rocketchat.loadbalancer.stickiness=true , when i run docker-compose up I will get the following error on trafik log and the service will not be published:
traefik | time="2020-03-31T19:44:02-03:00" level=error msg="field not found, node: stickiness" providerName=docker container=rocketchat-app-rocketchat-4bdd0903512908e37ad75dfedc7bd5b50c1626330c5eed130e77328a554a6500
With that line commented, the service runs, but I do not get stickiness.
cakiwi
March 31, 2020, 11:33pm
2
It is:
- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie=true"
If you want to name the cookie:
- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie.name=foo"
https://docs.traefik.io/v2.1/routing/providers/docker/#services
ldez
April 1, 2020, 12:03am
4
It's:
- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie=true"
1 Like
@cakiwi thanks, it worked.
cakiwi
April 1, 2020, 2:10pm
6
@Idez : Weird, in my testing using that I get:
level=error msg="cookie cannot be a standalone element (type *dynamic.Cookie)" providerName=docker
But
- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie.name
Is the minimum I could use to get it working.
Traefik2.2
docker-compose.yaml
version: "3.7"
services:
traefik:
image: traefik:2.2
ports:
- '80:80'
- '443:443'
- '8080:8080'
command:
- --entrypoints.http.address=:80
- --entrypoints.https.address=:443
- --entrypoints.http8080.address=:8080
- --api=true
- --providers.docker=true
labels:
- "traefik.http.routers.api.entrypoints=http8080"
- "traefik.http.routers.api.rule=HostRegexp(`{any:.*}`)"
- "traefik.http.routers.api.service=api@internal"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: whoami
labels:
- "traefik.http.routers.rocketchat.rule=PathPrefix(`/whoami`)"
- "traefik.http.routers.rocketchat.middlewares=rocketchat"
- "traefik.http.middlewares.rocketchat.stripprefix.prefixes=/whoami"
- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie.name"
#- "traefik.http.services.rocketchat.loadbalancer.sticky.cookie=true"
ldez
April 1, 2020, 4:22pm
7
traefik.http.services.rocketchat.loadbalancer.sticky.cookie.name
is not a valid label: a label is a pair of key and value: it's a map
ldez
April 1, 2020, 4:39pm
8
but I confirmed that traefik.http.services.whoami.loadbalancer.sticky.cookie=true
don't works as I expect, so I will change that.
version: "3.7"
services:
traefik:
image: traefik:2.2
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.websecure.address=:443
- --api
- --providers.docker
- --providers.docker.exposedbydefault=false
labels:
traefik.enable: true
# Dashboard
traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
traefik.http.routers.traefik.entrypoints: websecure
traefik.http.routers.traefik.service: api@internal
whoami:
image: containous/whoami:v1.5.0
labels:
traefik.enable: true
traefik.http.routers.whoami.rule: Host(`whoami.localhost`)
traefik.http.routers.whoami.entrypoints: websecure
traefik.http.services.whoami.loadbalancer.sticky.cookie.name: ''
cakiwi
April 1, 2020, 8:35pm
9
It is valid syntax, it creates a label with an empty value (key=""). Therefore a valid label.
ref: docker run
ref: compose file
ldez
April 1, 2020, 8:43pm
10
ok I didn't know that.
But I recommend to not use it because some people think that xxx.yyy
label is like aCLI flag: a boolean value.