From 7d1e3c3860639c0dc826d20706a5f894b2dc7613 Mon Sep 17 00:00:00 2001 From: Bret Fisher Date: Mon, 4 Feb 2019 01:23:18 -0500 Subject: [PATCH] make logging config a template --- stack-ee-ghost.yml | 14 +++++++++++++- stack-elk.yml | 26 +++++++++++++------------- stack-ghost.yml | 26 +++++++++++++------------- stack-menu.yml | 16 +++++++++++----- stack-portainer.yml | 18 ++++++++++++------ stack-proxy.yml | 13 ++++++++++--- stack-prune.yml | 18 ++++++++++++------ stack-rexray.yml | 15 +++++++++++---- stack-sqlite-ghost.yml | 16 +++++++++++----- stack-swarmprom.yml | 39 +++++++++++++++++---------------------- stack-visualizer.yml | 13 ++++++------- 11 files changed, 129 insertions(+), 85 deletions(-) diff --git a/stack-ee-ghost.yml b/stack-ee-ghost.yml index 4400f0b..6772a82 100644 --- a/stack-ee-ghost.yml +++ b/stack-ee-ghost.yml @@ -1,8 +1,18 @@ -version: '3.2' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: ghost: + <<: *default-opts image: ghost:1-alpine environment: # see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables @@ -20,6 +30,7 @@ services: db: + <<: *default-opts image: mysql:5.7 volumes: - db:/var/lib/mysql @@ -31,6 +42,7 @@ services: MYSQL_ROOT_PASSWORD_FILE: /run/secrets/ghost-db-password db-backup: + <<: *default-opts image: mysql:5.7 command: sh -c "while true; do /usr/bin/mysqldump -u root --password=$$(< $$MYSQL_ROOT_PASSWORD_FILE) --all-databases --host=db > /backup/backup$$(date +'%H').sql ; sleep 3600; done" volumes: diff --git a/stack-elk.yml b/stack-elk.yml index 43bf41c..607f2c6 100644 --- a/stack-elk.yml +++ b/stack-elk.yml @@ -1,8 +1,18 @@ -version: '3.5' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: elasticsearch: + <<: *default-opts image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.0 configs: - source: elastic_config @@ -16,11 +26,9 @@ services: deploy: mode: replicated replicas: 1 - logging: - options: - max-size: "500k" logstash: + <<: *default-opts image: docker.elastic.co/logstash/logstash-oss:6.4.0 ports: - "5000:5000" @@ -38,12 +46,9 @@ services: deploy: mode: replicated replicas: 1 - logging: - options: - max-size: "500k" - kibana: + <<: *default-opts image: docker.elastic.co/kibana/kibana-oss:6.4.0 configs: - source: kibana_config @@ -59,11 +64,6 @@ services: - traefik.frontend.rule=Host:kibana.dogvs.cat - traefik.frontend.auth.basic=${KIBANA_USER:-admin}:${KIBANA_PASSWORD:-$2y$05$oZcj4FgdSFEYNCH0EH/3Vu7Hp72gkvEadHzMsDhGFkbvS/ZrKMKfK} # TODO: make secrets secret - logging: - options: - max-size: "500k" - - configs: diff --git a/stack-ghost.yml b/stack-ghost.yml index 504d94b..e45d242 100644 --- a/stack-ghost.yml +++ b/stack-ghost.yml @@ -1,8 +1,18 @@ -version: '3.5' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: ghost: + <<: *default-opts image: ghost:alpine networks: - proxy @@ -20,12 +30,9 @@ services: labels: - traefik.port=2368 - traefik.frontend.rule=Host:ghost.dogvs.cat - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" db: + <<: *default-opts image: mysql:5.7 volumes: - db:/var/lib/mysql @@ -37,13 +44,10 @@ services: endpoint_mode: dnsrr environment: MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" # NOTE: table locking is a concern. Maybe use --single-transaction=TRUE for innoDB db-backup: + <<: *default-opts image: mysql:5.7 command: sh -c "while true; do /usr/bin/mysqldump -u root --password=$$(< $$MYSQL_ROOT_PASSWORD_FILE) --all-databases --host=db > /backup/backup$$(date +'%H').sql ; sleep 3600; done" volumes: @@ -57,10 +61,6 @@ services: deploy: restart_policy: delay: 600s - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" #TODO: backup for static content diff --git a/stack-menu.yml b/stack-menu.yml index fc2ce8e..c8c983b 100644 --- a/stack-menu.yml +++ b/stack-menu.yml @@ -1,8 +1,18 @@ -version: '3.4' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: menu: + <<: *default-opts image: dogvscat/menu build: context: menu @@ -11,10 +21,6 @@ services: labels: - traefik.port=80 - traefik.frontend.rule=Host:www.dogvs.cat,dogvs.cat - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" networks: - proxy diff --git a/stack-portainer.yml b/stack-portainer.yml index a9401e0..63bb889 100644 --- a/stack-portainer.yml +++ b/stack-portainer.yml @@ -1,7 +1,17 @@ -version: "3.4" +version: "3.7" + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: web: + <<: *default-opts image: portainer/portainer # command: -H "tcp://tasks.agent:9001" deploy: @@ -18,6 +28,7 @@ services: volumes: - web:/data agent: + <<: *default-opts image: portainer/agent networks: - portainer @@ -27,11 +38,6 @@ services: mode: global environment: AGENT_CLUSTER_ADDR: tasks.agent - logging: - options: - max-size: "500k" - - networks: proxy: diff --git a/stack-proxy.yml b/stack-proxy.yml index d142c73..f08d6ec 100644 --- a/stack-proxy.yml +++ b/stack-proxy.yml @@ -4,9 +4,19 @@ version: '3.7' +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" + services: traefik: + <<: *default-opts image: traefik:1.7-alpine networks: - proxy @@ -42,9 +52,6 @@ services: deploy: placement: constraints: [node.role == manager] - logging: - options: - max-size: "500k" volumes: acme: diff --git a/stack-prune.yml b/stack-prune.yml index f69187a..3d9fce8 100644 --- a/stack-prune.yml +++ b/stack-prune.yml @@ -1,7 +1,17 @@ -version: '3.1' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: image-prune: + <<: *default-opts image: docker command: sh -c "while true; do docker image prune -af; sleep 86400; done" networks: @@ -10,12 +20,8 @@ services: - /var/run/docker.sock:/var/run/docker.sock deploy: mode: global - # logging: - # driver: "gelf" - # options: - # gelf-address: "tcp://127.0.0.1:5000" networks: bridge: external: true - name: bridge \ No newline at end of file + name: bridge diff --git a/stack-rexray.yml b/stack-rexray.yml index eaf999f..e97eb85 100644 --- a/stack-rexray.yml +++ b/stack-rexray.yml @@ -1,12 +1,22 @@ -version: "3.5" +version: "3.7" # 1. WORKAROUND: would prefer this use null network driver, will use bride for now to avoid overlay # 2. TODO: would prefer on-failure restart_policy, but need to run this in script to look # for if plugin exists first before reinstalling # 3. TODO: would prefer this picks a driver version, and support driver updates +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" + services: plugin-rexray: + <<: *default-opts image: mavenugo/swarm-exec:17.03.0-ce networks: - bridge @@ -18,9 +28,6 @@ services: mode: global restart_policy: condition: none - logging: - options: - max-size: "500k" networks: bridge: diff --git a/stack-sqlite-ghost.yml b/stack-sqlite-ghost.yml index 66c119d..b995ce0 100644 --- a/stack-sqlite-ghost.yml +++ b/stack-sqlite-ghost.yml @@ -1,8 +1,18 @@ -version: '3.5' +version: '3.7' + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: ghost: + <<: *default-opts image: ghost:2-alpine networks: - proxy @@ -23,10 +33,6 @@ services: labels: - traefik.port=2368 - traefik.frontend.rule=Host:ghost.dogvs.cat - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" # TODO: backup for static content diff --git a/stack-swarmprom.yml b/stack-swarmprom.yml index 95b6514..3b39e4f 100644 --- a/stack-swarmprom.yml +++ b/stack-swarmprom.yml @@ -1,4 +1,13 @@ -version: "3.3" +version: "3.7" + +x-default-opts: + &default-opts + logging: + options: + max-size: "1m" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" networks: net: {} @@ -29,6 +38,7 @@ configs: services: dockerd-exporter: + <<: *default-opts image: stefanprodan/caddy networks: - net @@ -44,12 +54,10 @@ services: memory: 128M reservations: memory: 64M - logging: - options: - max-size: "500k" cadvisor: + <<: *default-opts image: google/cadvisor networks: - net @@ -67,12 +75,10 @@ services: memory: 128M reservations: memory: 64M - logging: - options: - max-size: "500k" grafana: + <<: *default-opts image: stefanprodan/swarmprom-grafana:5.3.4 networks: - net @@ -104,12 +110,10 @@ services: memory: 128M reservations: memory: 64M - logging: - options: - max-size: "500k" alertmanager: + <<: *default-opts image: stefanprodan/swarmprom-alertmanager:v0.14.0 networks: - net @@ -138,12 +142,10 @@ services: memory: 128M reservations: memory: 64M - logging: - options: - max-size: "500k" unsee: + <<: *default-opts image: cloudflare/unsee:v0.8.0 networks: - net @@ -158,12 +160,10 @@ services: - traefik.frontend.rule=Host:unsee.dogvs.cat - traefik.frontend.auth.basic=${UNSEE_USER:-admin}:${UNSEE_PASSWORD:-$2y$05$oZcj4FgdSFEYNCH0EH/3Vu7Hp72gkvEadHzMsDhGFkbvS/ZrKMKfK} # - com.df.users=${ADMIN_USER:-admin}:${ADMIN_PASSWORD:-admin} - logging: - options: - max-size: "500k" node-exporter: + <<: *default-opts image: stefanprodan/swarmprom-node-exporter:v0.16.0 networks: - net @@ -190,12 +190,10 @@ services: memory: 128M reservations: memory: 64M - logging: - options: - max-size: "500k" prometheus: + <<: *default-opts image: stefanprodan/swarmprom-prometheus:v2.5.0 networks: - net @@ -226,9 +224,6 @@ services: memory: 2048M reservations: memory: 128M - logging: - options: - max-size: "500k" diff --git a/stack-visualizer.yml b/stack-visualizer.yml index d46642d..d5eda30 100644 --- a/stack-visualizer.yml +++ b/stack-visualizer.yml @@ -1,14 +1,13 @@ -version: '3' +version: '3.7' -x-default-opts: &default-opts: +x-default-opts: + &default-opts logging: options: max-size: "1m" - - # logging: - # driver: "gelf" - # options: - # gelf-address: "udp://127.0.0.1:5000" + # driver: "gelf" + # options: + # gelf-address: "udp://127.0.0.1:5000" services: