diff --git a/.gitignore b/.gitignore index ecdc809..ea50b05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tags storage +influxdb/ diff --git a/configs/traefik.yml b/configs/traefik.yml new file mode 100644 index 0000000..8846042 --- /dev/null +++ b/configs/traefik.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 38d4ec5..24d5970 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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,16 +18,28 @@ 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: -internal consul://consul:8500 + 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: @@ -33,38 +47,54 @@ services: 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 - - portainer_data:/data + - ./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: traefik 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' + - 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" -volumes: - portainer_data: +networks: + traefik: + driver: bridge + name: traefik + inbound: + driver: bridge + name: inbound + +configs: + traefik_config: + file: ./configs/traefik.yml \ No newline at end of file diff --git a/fluent.conf b/fluent.conf deleted file mode 100644 index 840e9c7..0000000 --- a/fluent.conf +++ /dev/null @@ -1,26 +0,0 @@ - - @type forward - @id input1 - @label @mainstream - port ${LISTEN_PORT} - source_hostname_key hostname - - - - diff --git a/fluentd/Dockerfile b/fluentd/Dockerfile deleted file mode 100644 index 1446d54..0000000 --- a/fluentd/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM fluent/fluentd:latest - -RUN ["gem", "install", "fluent-plugin-influxdb", "--no-rdoc", "--no-ri"] diff --git a/fluentd/conf/fluent.conf b/fluentd/conf/fluent.conf deleted file mode 100644 index 4f268d8..0000000 --- a/fluentd/conf/fluent.conf +++ /dev/null @@ -1,20 +0,0 @@ - - @type forward - port 24224 - bind 0.0.0.0 - - - - @type copy - - @type influxdb - host influxdb_elena - dbname logging - port 8086 - tag_key @log_name - flush_interval 1s - - - @type stdout - - diff --git a/traefik-compose.yml b/traefik-compose.yml new file mode 100644 index 0000000..4015787 --- /dev/null +++ b/traefik-compose.yml @@ -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 diff --git a/traefik-stack.yml b/traefik-stack.yml new file mode 100644 index 0000000..45c7cdd --- /dev/null +++ b/traefik-stack.yml @@ -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