Skip to content

Latest commit

 

History

History
74 lines (54 loc) · 2.6 KB

README.md

File metadata and controls

74 lines (54 loc) · 2.6 KB

About

Warning

This stack is still in a work-in-progress state. Please use with caution.

An ingress service using Traefik Edge Router with LoadBalancer using HAProxy for Docker Swarm.

More information on Traefik and Docker can be found here.

Deploying the stack

First, retrieve the stack YML manifest:

curl -L https://raw.githubusercontent.com/swarmlibs/traefik-ingress/main/docker-stack.yml -o traefik-ingress-stack.yml

Create the following networks (if they don't already exist):

docker network create --driver=overlay --attachable public
docker network create --driver=overlay --attachable prometheus

Then use the downloaded YML manifest to deploy your stack:

docker stack deploy -c traefik-ingress-stack.yml traefik-ingress

Overviews

Accessing the Dashboard

The Traefik dashboard is available at http://<traefik-ip>:8080.

Deploying / Exposing Services

While in Swarm Mode, Traefik uses labels found on services, not on individual containers. Therefore, if you use a compose file with Swarm Mode, labels should be defined in the deploy part of your service. This behavior is only enabled for docker-compose version 3+ (Compose file reference).

services:
  my-container:
    networks:
      # Attach the service to the public network
      public:
    deploy:
      labels:
        # Enable Traefik for this service
        - traefik.enable=true
        # Define the router/service
        - traefik.http.routers.my-container.rule=Host(`example.com`)
        # - traefik.http.routers.my-container.service=my-container-service # optional, if only one service is defined
        - traefik.http.services.my-container-service.loadbalancer.server.port=8080
        # Enable TLS (optional)
        - traefik.http.routers.my-container.tls=true
        - traefik.http.routers.my-container.tls.certresolver=letsencrypt # or letsencrypt-staging

# Define the "public" network
networks:
  public:
    name: public
    external: true

Read more about Traefik labels here.