Last active
March 16, 2021 07:35
-
-
Save nicosingh/26c9c5e19214c70f471e5020ee58f2ab to your computer and use it in GitHub Desktop.
Trœfik load balancing sample using docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3.4" | |
| services: | |
| proxy: | |
| image: traefik:latest | |
| restart: always | |
| ports: | |
| - 80:80 | |
| - 443:443 | |
| - 15671:8080 | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock | |
| command: --api --docker | |
| django: | |
| image: containous/whoami:latest | |
| restart: always | |
| labels: | |
| - "traefik.backend=django" | |
| - "traefik.frontend.rule=Path:/api/,/admin/" | |
| kibana: | |
| image: containous/whoami:latest | |
| restart: always | |
| labels: | |
| - "traefik.backend=kibana" | |
| - "traefik.frontend.rule=Path:/ts/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3.4" | |
| x-logging: &logging | |
| driver: "json-file" | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| x-env-files: &env-files | |
| env_file: | |
| - .env | |
| - .secrets | |
| services: | |
| postgis: | |
| image: mdillon/postgis:10 | |
| <<: *env-files | |
| volumes: | |
| - /home/ec2-user/postgres-db:/var/lib/postgresql/data | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-postgres | |
| postgis-exporter: | |
| image: wrouesnel/postgres_exporter:v0.4.6 | |
| <<: *env-files | |
| ports: | |
| - 9091:9187 | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-postgres | |
| django: | |
| image: registry.gitlab.com/inria-chile/tranque/backend:dev | |
| <<: *env-files | |
| volumes: | |
| - /home/ec2-user/www:/var/www | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| labels: | |
| - "traefik.port=8000" | |
| - "traefik.backend=django" | |
| - "traefik.djangoadmin.frontend.rule=PathPrefix:/admin;ReplacePathRegex:^/admin/(.*)" | |
| - "traefik.djangoapi.frontend.rule=PathPrefix:/api;ReplacePathRegex:^/api/(.*)" | |
| logging: *logging | |
| depends_on: | |
| - postgis | |
| cron: | |
| image: registry.gitlab.com/inria-chile/tranque/config/cron:dev | |
| <<: *env-files | |
| logging: *logging | |
| depends_on: | |
| - django | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| frontend: | |
| image: registry.gitlab.com/inria-chile/tranque/frontend:dev | |
| <<: *env-files | |
| volumes: | |
| - /home/ec2-user/www:/var/www | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| restart_policy: | |
| condition: on-failure | |
| labels: | |
| - "traefik.port=80" | |
| - "traefik.backend=frontend" | |
| - "traefik.front.frontend.rule=PathPrefix:/;ReplacePathRegex:^/(.*)" | |
| logging: *logging | |
| operations-frontend: | |
| image: registry.gitlab.com/inria-chile/tranque/operations-frontend:dev | |
| <<: *env-files | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| restart_policy: | |
| condition: on-failure | |
| labels: | |
| - "traefik.port=80" | |
| - "traefik.backend=operationsfrontend" | |
| - "traefik.operationsfrontend.frontend.rule=PathPrefix:/ops;ReplacePathRegex:^/ops/(.*)" | |
| logging: *logging | |
| proxy: | |
| image: traefik:latest | |
| <<: *env-files | |
| depends_on: | |
| - frontend | |
| - django | |
| - kibana | |
| deploy: | |
| placement: | |
| constraints: | |
| - node.role == manager | |
| restart_policy: | |
| condition: on-failure | |
| logging: *logging | |
| ports: | |
| - 80:80 | |
| - 443:443 | |
| - 8080:8080 | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock | |
| command: --api --docker --docker.swarmmode --debug | |
| amqpbroker: | |
| image: rabbitmq:3.7.8-management-alpine | |
| <<: *env-files | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| volumes: | |
| - /home/ec2-user/nginx-certs:/certs | |
| ports: | |
| - 15671:15671 | |
| amqpbroker-exporter: | |
| image: kbudde/rabbitmq-exporter:v0.29.0 | |
| <<: *env-files | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| ports: | |
| - 9093:9090 | |
| elasticsearch: | |
| image: registry.gitlab.com/inria-chile/tranque/config/elasticsearch:dev | |
| <<: *env-files | |
| volumes: | |
| - /home/ec2-user/elasticsearch-db:/usr/share/elasticsearch/data | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-elasticsearch | |
| elasticsearch-exporter: | |
| image: justwatch/elasticsearch_exporter:1.0.2 | |
| command: '-es.uri=http://elasticsearch:9200' | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-elasticsearch | |
| ports: | |
| - 9092:9108 | |
| kibana: | |
| image: registry.gitlab.com/inria-chile/tranque/config/kibana:dev | |
| depends_on: | |
| - elasticsearch | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - node.role != manager | |
| labels: | |
| - "traefik.port=5601" | |
| - "traefik.backend=kibana" | |
| - "traefik.kibana.frontend.rule=Path:/ts/" | |
| logstash: | |
| image: registry.gitlab.com/inria-chile/tranque/config/logstash:dev | |
| <<: *env-files | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| depends_on: | |
| - elasticsearch | |
| - amqpbroker | |
| - redis | |
| logging: *logging | |
| logstash-exporter: | |
| image: bonniernews/logstash_exporter:v0.1.2 | |
| command: '--web.listen-address=":9090" --logstash.endpoint=http://logstash:9600' | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| ports: | |
| - 9094:9090 | |
| enrichment: | |
| image: registry.gitlab.com/inria-chile/tranque/enrichment:dev | |
| <<: *env-files | |
| depends_on: | |
| - elasticsearch | |
| - amqpbroker | |
| - django | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| redis: | |
| image: redis:4-alpine | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| redis-exporter: | |
| image: oliver006/redis_exporter:v0.21.2 | |
| <<: *env-files | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-broker | |
| ports: | |
| - 9095:9121 | |
| fake-beats: | |
| image: registry.gitlab.com/inria-chile/tranque/fake-beats:dev | |
| <<: *env-files | |
| depends_on: | |
| - redis | |
| logging: *logging | |
| deploy: | |
| placement: | |
| constraints: | |
| - engine.labels.tranque.server.type == worker-backend | |
| docker-exporter: | |
| image: google/cadvisor:v0.28.3 | |
| command: -logtostderr -docker_only | |
| logging: *logging | |
| volumes: | |
| - /var/run/docker.sock:/var/run/docker.sock:ro | |
| - /:/rootfs:ro | |
| - /var/run:/var/run | |
| - /sys:/sys:ro | |
| - /var/lib/docker/:/var/lib/docker:ro | |
| deploy: | |
| mode: global | |
| ports: | |
| - 9090:8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment