ict-architecture
Labo 03: Traefik in Docker Swarm
Configuratie en deployen van de Traefik reverse proxy in een Swarm cluster.
Netwerk Setup
docker network create --driver=overlay traefik-publicMaak een overlay netwerk aan voor communicatie tussen Traefik en services.
Testen
curl -H "Host: whoami.localhost" http://<IP-MANAGER>Test de routing via de command line met curl headers.
Bestanden & Configuraties
traefik-stack.yaml
yaml
version: '3.8'services: traefik: image: traefik:v3.1 command: - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.swarmMode=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" ports: - "80:80" - "8080:8080" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro" networks: - traefik-public deploy: placement: constraints: - node.role == managernetworks: traefik-public: external: trueTraefik proxy configuratie voor Swarm API routing.
whoami-stack.yaml
yaml
version: '3.8'services: whoami: image: traefik/whoami networks: - traefik-public deploy: labels: - "traefik.enable=true" - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)" - "traefik.http.routers.whoami.entrypoints=web" - "traefik.http.services.whoami.loadbalancer.server.port=80"networks: traefik-public: external: trueVoorbeeld service met Traefik labels voor dynamische routing.