traefik config

This commit is contained in:
Aleksander Cynarski 2020-10-05 17:25:03 +02:00
parent fbd40e6c9c
commit afe1019b49
7 changed files with 206 additions and 77 deletions

18
configs/traefik.yml Normal file
View File

@ -0,0 +1,18 @@
log:
level: DEBUG
providers:
docker:
exposedByDefault: true
network: inbound
defaultRule: "Host(`{{ trimPrefix `/` .Name }}.docker.localhost`)"
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
api:
dashboard: true
debug: true
global:
sendAnonymousUsage: false
checkNewVersion: true

View File

@ -1,9 +1,11 @@
version: '2'
version: '3.8'
services:
consul:
image: consul
restart: always
container_name: consul_elena
container_name: consul
command: consul agent -server -dev -client=0.0.0.0 -ui -bootstrap -log-level warn -datacenter dev
environment:
SERVICE_8400_NAME: consul
@ -16,54 +18,83 @@ services:
- "8400:8400"
- "8500:8500"
- "8600:8600/udp"
expose:
- "8500"
networks:
- inbound
labels:
- "traefik.docker.network=inbound"
- "traefik.http.routers.consul.rule=Host(`consul.docker.localhost`)"
- "traefik.http.routers.consul.service=consul"
- "traefik.http.services.consul.loadbalancer.server.port=8500"
registrator:
restart: always
container_name: registrator_elena
container_name: registrator
depends_on:
- consul
image: gliderlabs/registrator:master
command: -ttl=120 -ttl-refresh=10 -cleanup=true -resync=10 -internal consul://consul:8500
volumes:
- /var/run/docker.sock:/tmp/docker.sock
networks:
- inbound
links:
- consul
environment:
SERVICE_NAME: registrator
portainer:
restart: always
container_name: portainer_elena
image: portainer/portainer
container_name: portainer
image: portainer/portainer-ce:latest
command: -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./storage/portainer:/data
networks:
- inbound
labels:
- "traefik.docker.network=inbound"
- "traefik.http.routers.portainer.rule=Host(`portainer.docker.localhost`)"
- "traefik.http.routers.portainer.service=portainer"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
fluentd:
build: ./fluentd
traefik:
image: traefik:latest
container_name: traefikervice=consul"
restart: always
container_name: fluentd_elena
networks:
- traefik
- inbound
volumes:
- ./fluentd/conf:/fluentd/etc
links:
- "influxdb"
- ./configs/traefik.yml:/etc/traefik/traefik.yml
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 24224:24224
environment:
SERVICE_24224_NAME: 'fluentd'
SERVICE_5140_NAME: 'fluentd'
influxdb:
image: influxdb:latest
restart: always
container_name: influxdb_elena
volumes:
- ./storage/influxdb/data:/var/lib/influxdb
environment:
INFLUXDB_DATA_ENGINE: 'tsm1'
INFLUXDB_REPORTING_DISABLED: 'false'
SERVICE_8086_NAME: 'influxdb'
SERVICE_8086_TAG: 'db'
- target: 80
published: 80
mode: host
- target: 443
published: 443
mode: host
- target: 8080
published: 8090
protocol: tcp
mode: ingress
labels:
- "traefik.http.routers.api.rule=Host(`traefik.docker.localhost`)"
- "traefik.http.routers.api.service=api@internal"
networks:
traefik:
driver: bridge
name: traefik
inbound:
driver: bridge
name: inbound
configs:
traefik_config:
file: ./configs/traefik.yml

View File

@ -1,26 +0,0 @@
<source>
@type forward
@id input1
@label @mainstream
port ${LISTEN_PORT}
source_hostname_key hostname
</source>
<label @mainstream>
<filter **>
@type record_transformer
<record>
tag ${tag}
hostname ${hostname}
</record>
</filter>
<match **>
type influxdb
host ${DB_HOST}
port ${DB_PORT}
dbname ${DB_NAME}
collection ${DB_COLLECTION}
flush_interval ${FLUSH_INTERVAL}
</match>
</label>

View File

@ -1,3 +0,0 @@
FROM fluent/fluentd:latest
RUN ["gem", "install", "fluent-plugin-influxdb", "--no-rdoc", "--no-ri"]

View File

@ -1,20 +0,0 @@
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<match *.**>
@type copy
<store>
@type influxdb
host influxdb_elena
dbname logging
port 8086
tag_key @log_name
flush_interval 1s
</store>
<store>
@type stdout
</store>
</match>

48
traefik-compose.yml Normal file
View File

@ -0,0 +1,48 @@
version: '3.7'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: always
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--metrics.prometheus.addServicesLabels=true"
- "--metrics.prometheus=true"
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
- "--entryPoints.web.address=:80"
- "--entryPoints.traefik.address=:8080"
- "--providers.docker=true"
- "--providers.docker.swarmmode=false"
- "--providers.docker.watch"
- "--api=true"
- "--api.insecure=true"
networks:
- traefik
- inbound
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- target: 80
published: 80
mode: host
- target: 443
published: 443
mode: host
- target: 8080
published: 8090
protocol: tcp
mode: ingress
labels:
- "traefik.http.routers.api.rule=Host(`traefik.docker.localhost`)"
- "traefik.http.routers.api.service=api@internal"
networks:
traefik:
driver: bridge
name: traefik
inbound:
driver: bridge
name: inbound

81
traefik-stack.yml Normal file
View File

@ -0,0 +1,81 @@
version: '3.7'
services:
traefik:
image: traefik:latest
restart: always
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--metrics.prometheus.addServicesLabels=true"
- "--metrics.prometheus=true"
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
- "--entryPoints.web.address=:80"
- "--tracing.zipkin.httpEndpoint=http://jaeger:9411/api/v2/spans"
- "--entryPoints.traefik.address=:8080"
- "--providers.docker=true"
- "--providers.docker.swarmmode=false"
- "--providers.docker.watch"
networks:
- traefik
- inbound
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- target: 80
published: 80
mode: host
- target: 443
published: 443
mode: host
mode: host
- target: 8080
published: 8090
protocol: tcp
mode: ingress
deploy:
mode: global
placement:
constraints:
- node.role == manager
update_config:
parallelism: 1
delay: 10s
restart_policy:
condition: on-failure
jaeger:
image: jaegertracing/all-in-one:1.6
restart: always
environment:
COLLECTOR_ZIPKIN_HTTP_PORT: 9411
ports:
- 5775:5775/udp
- 6831:6831/udp
- 6832:6832/udp
- 5778:5778
- 16686:16686
- 14268:14268
- 9411:9411
networks:
- inbound
- traefik
deploy:
labels:
- "traefik.docker.network=inbound"
- "traefik.http.routers.jaeger.rule=Host(`jaeger.localhost`)"
- "traefik.http.routers.jaeger.service=jaeger"
- "traefik.http.services.jaeger.loadbalancer.server.port=16686"
placement:
constraints:
- node.role==manager
restart_policy:
condition: on-failure
networks:
traefik:
driver: overlay
name: traefik
inbound:
driver: overlay
name: inbound