J'essaie d'exécuter docker-compose up --scale apiserver=2
mais Traefic ne peut pas équilibrer la charge du serveur api. Je vois les deux applications sur le tableau de bord mais Traefic n'arrive à équilibrer que la première. Lorsque je vérifie les logs, je vois que les deux applications nodejs sont lancées.
apiserver_1_cff59924db38 | Listening on port 3000. ContainerId: a2793ccb-daee-4a73-b4d0-6cbccb616cb9
apiserver_2_2164f88b7ed4 | Listening on port 3000. ContainerId: a92f516a-d66c-4672-b1b9-e0d8e182b46f
Lorsque je consulte le tableau de bord de Traefik, je vois ce qui suit,
backend-apiserver-dockertest
|Server |Weight|
|----------------------|------|
|http://172.18.0.3:3000| 1 |
|http://172.18.0.6:3000| 1 |
Load Balancer
Method wrr
Cependant, chaque fois que j'appuie sur ${API_NAME}
Je n'obtiens une réponse que de la première instance du serveur API. Ce qui me donne l'UUID du premier serveur a2793ccb-daee-4a73-b4d0-6cbccb616cb9
Voici mon fichier docker-compse.yml
version: '3.6'
services:
traefik:
container_name: traefik
image: traefik
ports:
- 80:80
- 443:443
- 8080:8080 #dashboard
networks:
- proxy
environment:
- DUCKDNS_TOKEN=${DUCKDNS_TOKEN}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik/traefik.toml:/traefik.toml
- ./traefik/acme/acme.json:/etc/traefik/acme.json
- ./log:/var/log/traefik
labels:
- traefik.enable=true
- traefik.port=8080
- traefik.frontend.rule=Host:${TRAEFIK_NAME}
restart: unless-stopped
apiserver:
build: ./api-server
networks:
- proxy
labels:
- traefik.frontend.rule=Host:${API_NAME}
- traefik.frontend.entryPoints=https
- traefik.docker.network=proxy
- traefik.protocol=http
- traefik.enable=true
- traefik.port=3000
restart: unless-stopped
website:
container_name: website
build: ./website
networks:
- proxy
labels:
- traefik.frontend.rule=Host:${DOMAIN_NAME}
- traefik.frontend.entryPoints=https
- traefik.docker.network=proxy
- traefik.protocol=http
- traefik.enable=true
- traefik.port=80
restart: unless-stopped
networks:
proxy:
name: proxy
traefik.toml
debug = true
logLevel = "DEBUG"
checkNewVersion = true
defaultEntryPoints = ["http", "https"]
[api]
# Name of the related entry point
#
# Optional
# Default: "traefik"
#
entryPoint = "traefik"
# Enable Dashboard
#
# Optional
# Default: true
#
dashboard = true
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[docker]
endpoint = "unix:///var/run/docker.sock"
exposedbydefault = false
watch = true
[acme]
email = "email@address.com"
storage = "/etc/traefik/acme.json"
entryPoint = "https"
acmeLogging = false
[acme.dnsChallenge]
provider = "duckdns"
delayBeforeCheck = 0
[[acme.domains]]
main = "*.mydomain.duckdns.org"
sans = ["mydomain.duckdns.org"]