Traefik Docker Swarm: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie: Docker Kategorie: Traefik = Netzwerkplan = {{#drawio-traefik-docker-swarm-01}} = Traefik Konfiguration = = Docker Swarm Dienst =“) |
|||
| (6 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
[[Kategorie: Docker]] | [[Kategorie: Docker]] | ||
[[Kategorie: Traefik]] | [[Kategorie: Traefik]] | ||
| − | |||
= Netzwerkplan = | = Netzwerkplan = | ||
| − | {{#drawio | + | {{#drawio:traefik-docker-swarm-01}} |
= Traefik Konfiguration = | = Traefik Konfiguration = | ||
| + | * Vorraussetzung für SSH-Endpunkt: [[Traefik Docker SSH]] | ||
| + | * Der Traefik-Host muss Teil des Swarms sein | ||
| + | * '''mkdir ''traefik'' ''' | ||
| + | * '''cd ''traefik'' ''' | ||
| + | * '''vim ''docker-compose.yml'' ''' | ||
| + | |||
| + | <syntaxhighlight lang="yaml"> | ||
| + | version: '3' | ||
| + | |||
| + | services: | ||
| + | reverse-proxy: | ||
| + | image: lzxinux/traefik-ssh | ||
| + | command: | ||
| + | - "--api.insecure=true" | ||
| + | - "--providers.docker.endpoint=unix:///var/run/docker.sock" | ||
| + | - "--providers.swarm.endpoint=ssh://traefik@10.81.3.21" | ||
| + | - "--providers.swarm.network=test-net" | ||
| + | ports: | ||
| + | - "80:80" | ||
| + | - "8888:8080" | ||
| + | volumes: | ||
| + | - /var/run/docker.sock:/var/run/docker.sock | ||
| + | - ./ssh/:/root/.ssh | ||
| + | networks: | ||
| + | - default | ||
| + | - test-net | ||
| + | whoami: | ||
| + | image: traefik/whoami | ||
| + | labels: | ||
| + | - "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`) || Path(`/`)" | ||
| + | networks: | ||
| + | test-net: | ||
| + | driver: overlay | ||
| + | external: true | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | * '''docker-compose up -d''' | ||
| + | * '''docker-compose logs -f''' | ||
= Docker Swarm Dienst = | = Docker Swarm Dienst = | ||
| + | * '''mkdir ''apache2'' ''' | ||
| + | * '''cd ''apache2'' ''' | ||
| + | * '''vim ''docker-stack.yml'' ''' | ||
| + | |||
| + | <syntaxhighlight lang="yaml"> | ||
| + | version: "3.7" | ||
| + | services: | ||
| + | my_web: | ||
| + | image: ubuntu/apache2 | ||
| + | networks: | ||
| + | - test-net | ||
| + | deploy: | ||
| + | replicas: 2 | ||
| + | labels: | ||
| + | - "traefik.http.services.my_web.loadbalancer.server.port=80" | ||
| + | - "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)" | ||
| + | - "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)" | ||
| + | - "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1" | ||
| + | - "traefik.http.routers.my_web.middlewares=test-path" | ||
| + | volumes: | ||
| + | - ./html/:/var/www/html/ | ||
| + | |||
| + | networks: | ||
| + | test-net: | ||
| + | driver: overlay | ||
| + | external: true | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | * '''docker stack deploy --compose-file ''docker-stack.yml'' ubuntu-apache2''' | ||
| + | |||
| + | = Monitor = | ||
| + | * Das Dashboard von Traefik wird unter Port 8888 erreichbar sein | ||
| + | * Die Seite sollte sich selbst aktualisieren solange Traefik aktiv ist | ||
Aktuelle Version vom 13. November 2024, 13:48 Uhr
Netzwerkplan
Traefik Konfiguration
- Vorraussetzung für SSH-Endpunkt: Traefik Docker SSH
- Der Traefik-Host muss Teil des Swarms sein
- mkdir traefik
- cd traefik
- vim docker-compose.yml
version: '3'
services:
reverse-proxy:
image: lzxinux/traefik-ssh
command:
- "--api.insecure=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.swarm.endpoint=ssh://traefik@10.81.3.21"
- "--providers.swarm.network=test-net"
ports:
- "80:80"
- "8888:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./ssh/:/root/.ssh
networks:
- default
- test-net
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.traefik`) || Path(`/`)"
networks:
test-net:
driver: overlay
external: true
- docker-compose up -d
- docker-compose logs -f
Docker Swarm Dienst
- mkdir apache2
- cd apache2
- vim docker-stack.yml
version: "3.7"
services:
my_web:
image: ubuntu/apache2
networks:
- test-net
deploy:
replicas: 2
labels:
- "traefik.http.services.my_web.loadbalancer.server.port=80"
- "traefik.http.routers.my_web.rule=Host(`apache.ubuntu`) || PathPrefix(`/apache`)"
- "traefik.http.middlewares.test-path.replacepathregex.regex=^/apache(.*)"
- "traefik.http.middlewares.test-path.replacepathregex.replacement=/$$1"
- "traefik.http.routers.my_web.middlewares=test-path"
volumes:
- ./html/:/var/www/html/
networks:
test-net:
driver: overlay
external: true
- docker stack deploy --compose-file docker-stack.yml ubuntu-apache2
Monitor
- Das Dashboard von Traefik wird unter Port 8888 erreichbar sein
- Die Seite sollte sich selbst aktualisieren solange Traefik aktiv ist
