kalxasus пре 6 година
комит
87d92e6bc4

+ 4 - 0
services/.env

@@ -0,0 +1,4 @@
+# variables for registrator
+SERVICE_TAGS=production
+#
+SAAS_CLUSTER=production

+ 27 - 0
services/README.md

@@ -0,0 +1,27 @@
+
+## Deploy web-app
+
+```
+docker stack deploy --compose-file cli-app.yml client-app
+docker stack ps client-app |grep -v Shutdown |grep web-app |grep -v catalog
+```
+
+## Deploy api
+
+```
+docker stack deploy --compose-file cli-api.yml client-app
+docker stack ps client-app |grep -v Shutdown |grep api |grep -v catalog
+```
+
+## Deploy daemons
+
+```
+docker stack deploy --compose-file cli-daemons.yml client-daemons
+docker stack ps client-app |grep -v Shutdown |grep daemons
+```
+
+## RabbitMQ
+
+```
+docker stack deploy --compose-file docker-rabbitmq.yml client-rabbitmq
+```

+ 44 - 0
services/cli-api.yml

@@ -0,0 +1,44 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+services:
+
+  api:
+    image: registry.orbita1.ru/client/api:latest
+    ports:
+      - target: 9000
+        published: 9000
+        mode: host
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+    env_file:
+      - .env
+    environment:
+      # params for registrator
+      - SERVICE_NAME=client-api
+      - SERVICE_9000_CHECK_TCP=true
+      - SERVICE_9000_CHECK_INTERVAL=15s
+      - SERVICE_9000_CHECK_TIMEOUT=3s
+      - SERVICE_CHECK_DEREGISTER_AFTER=1m
+      - LOG_OUTPUT=gelf
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+

+ 45 - 0
services/cli-app.yml

@@ -0,0 +1,45 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+services:
+
+  web-app:
+    image: registry.orbita1.ru/client/app:latest
+    ports:
+      - target: 80
+        published: 8001
+        mode: host
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+    env_file:
+      - .env
+    environment:
+      - CDN_URL=
+      - API_DOMAIN=/api/
+      # params for registrator
+      - SERVICE_80_NAME=client-web-app
+      - SERVICE_80_CHECK_TCP=true
+      - SERVICE_80_CHECK_INTERVAL=15s
+      - SERVICE_80_CHECK_TIMEOUT=3s
+      - SERVICE_CHECK_DEREGISTER_AFTER=1m
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+

+ 34 - 0
services/cli-daemons.yml

@@ -0,0 +1,34 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+services:
+
+  daemons:
+    image: registry.orbita1.ru/client/supervisord:latest
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+    env_file:
+      - .env
+    environment:
+      - SERVICE_IGNORE=true
+      - LOG_OUTPUT=gelf
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"

+ 53 - 0
services/docker-consul.yml

@@ -0,0 +1,53 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+volumes:
+  consul-data:
+
+services:
+  consul:
+    image: consul:1.4.0
+    # will be used as consul node name (alphanum and dash only)
+    hostname: "{{.Node.Hostname}}"
+#    ports:
+#      - target: 8500
+#        published: 8500
+#        mode: host
+    command: "agent -server -retry-join consul.server -ui -client 0.0.0.0"
+    environment:
+      - CONSUL_BIND_INTERFACE=eth0
+      - 'CONSUL_LOCAL_CONFIG={
+          "datacenter":"client",
+          "leave_on_terminate": true,
+          "skip_leave_on_interrupt": true,
+          "autopilot": {
+            "cleanup_dead_servers": true
+          },
+          "bootstrap_expect": 2,
+          "disable_update_check": true,
+          "disable_host_node_id": true
+        }'
+    networks:
+      client-net:
+        aliases:
+          - consul.server
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    volumes:
+      - consul-data:/consul/data
+    labels:
+      - "SERVICE_IGNORE=yes"
+

+ 112 - 0
services/docker-rabbitmq.yml

@@ -0,0 +1,112 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+volumes:
+  rabbitmq-01-data:
+  rabbitmq-02-data:
+  rabbitmq-03-data:
+
+services:
+
+  rabbitmq-01:
+    image: rabbitmq:3.7-management-alpine
+    hostname: "{{.Node.Hostname}}-rabbitmq"
+    env_file:
+      - .env
+    environment:
+      - RABBITMQ_DEFAULT_USER=admin
+      - RABBITMQ_DEFAULT_PASS=kokoko
+      - RABBITMQ_ERLANG_COOKIE="kokokokok"
+    labels:
+      # params for registrator
+      - "SERVICE_5672_NAME=rabbitmq"
+      - "SERVICE_4369_IGNORE=true"
+      - "SERVICE_5671_IGNORE=true"
+      - "SERVICE_15671_IGNORE=true"
+      - "SERVICE_15672_IGNORE=true"
+      - "SERVICE_25672_IGNORE=true"
+    volumes:
+      - rabbitmq-01-data:/var/lib/rabbitmq
+    networks:
+      client-net:
+        aliases:
+          - prod1b-rabbitmq
+    deploy:
+      mode: global
+      placement:
+        constraints: [node.labels.rabbitmq1 == true]
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+
+  rabbitmq-02:
+    image: rabbitmq:3.7-management-alpine
+    hostname: "{{.Node.Hostname}}-rabbitmq"
+    env_file:
+      - .env
+    environment:
+      - RABBITMQ_DEFAULT_USER=admin
+      - RABBITMQ_DEFAULT_PASS=kokoko
+      - RABBITMQ_ERLANG_COOKIE="kokokokok"
+    labels:
+      # params for registrator
+      - "SERVICE_5672_NAME=rabbitmq"
+      - "SERVICE_4369_IGNORE=true"
+      - "SERVICE_5671_IGNORE=true"
+      - "SERVICE_15671_IGNORE=true"
+      - "SERVICE_15672_IGNORE=true"
+      - "SERVICE_25672_IGNORE=true"
+    volumes:
+      - rabbitmq-02-data:/var/lib/rabbitmq
+    networks:
+      client-net:
+        aliases:
+          - prod2b-rabbitmq
+    deploy:
+      mode: global
+      placement:
+        constraints: [node.labels.rabbitmq2 == true]
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+
+  rabbitmq-03:
+    image: rabbitmq:3.7-management-alpine
+    hostname: "{{.Node.Hostname}}-rabbitmq"
+    env_file:
+      - .env
+    environment:
+      - RABBITMQ_DEFAULT_USER=admin
+      - RABBITMQ_DEFAULT_PASS=kokoko
+      - RABBITMQ_ERLANG_COOKIE="kokokokok"
+    labels:
+      # params for registrator
+      - "SERVICE_5672_NAME=rabbitmq"
+      - "SERVICE_4369_IGNORE=true"
+      - "SERVICE_5671_IGNORE=true"
+      - "SERVICE_15671_IGNORE=true"
+      - "SERVICE_15672_IGNORE=true"
+      - "SERVICE_25672_IGNORE=true"
+    volumes:
+      - rabbitmq-03-data:/var/lib/rabbitmq
+    networks:
+      client-net:
+        aliases:
+          - prod3b-rabbitmq
+    deploy:
+      mode: global
+      placement:
+        constraints: [node.labels.rabbitmq3 == true]
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"

+ 144 - 0
services/docker-services.yml

@@ -0,0 +1,144 @@
+version: "3.7"
+
+#docker network create -d overlay --attachable client-net
+networks:
+  client-net:
+    external: true
+
+volumes:
+  redis-data:
+
+services:
+  registrator:
+    image: marcuslinke/registrator:2017-10-25
+#    image: gliderlabs/registrator:latest
+    hostname: "{{.Node.Hostname}}"
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+    volumes:
+      - /var/run/docker.sock:/tmp/docker.sock
+    command:
+      - -cleanup=true
+      - -internal
+      - -deregister=always
+      - -swarm-replicas-aware=false
+#      - -swarm-manager-servicename=swarm
+      - -resync=15
+      - -ttl=15
+      - -ttl-refresh=10
+      - -retry-interval=2000
+      - consul://consul.server:8500
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+
+  vault:
+    image: vault:latest
+    hostname: "{{.Node.Hostname}}"
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+#    ports:
+#      - target: 8200
+#        published: 8200
+#        mode: host
+#    volumes:
+#      - ./configs/vault/policies:/vault/policies
+#      - ./configs/vault/secrets:/vault/secrets
+    command: server
+    environment:
+      - 'VAULT_LOCAL_CONFIG=
+          {
+            "backend": {
+              "consul": {
+                "address":"consul:8500",
+                "disable_registration": "true"
+              }
+            },
+            "listener":{
+              "tcp": {
+                "address": "0.0.0.0:8200",
+                "tls_disable": 1
+              }
+            },
+            "disable_mlock": "true"
+          }'
+      - SKIP_SETCAP=1
+      - VAULT_UI=1
+      - VAULT_ADDR=http://127.0.0.1:8200
+      - VAULT_CLUSTER_INTERFACE=eth0
+      - VAULT_API_ADDR=http://vault
+      # params for registrator
+      - SERVICE_8200_NAME=vault
+      - SERVICE_8200_TAGS=production
+      - SERVICE_8200_CHECK_TCP=true
+      - SERVICE_8200_CHECK_INTERVAL=15s
+      - SERVICE_8200_CHECK_TIMEOUT=3s
+      - SERVICE_CHECK_DEREGISTER_AFTER=1m
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+
+  redis:
+    image: redis:alpine
+    hostname: "{{.Node.Hostname}}"
+    deploy:
+      mode: global
+      endpoint_mode: dnsrr
+      update_config:
+        parallelism: 1
+        failure_action: rollback
+        delay: 30s
+      restart_policy:
+        condition: any
+        delay: 5s
+        window: 120s
+    networks:
+      - client-net
+#    ports:
+#      - target: 6379
+#        published: 6379
+#        mode: host
+    volumes:
+      - redis-data:/data
+    labels:
+      - "SERVICE_NAME=redis"
+    env_file:
+      - .env
+    environment:
+      # params for registrator
+      - SERVICE_6379_CHECK_TCP=true
+      - SERVICE_6379_CHECK_INTERVAL=15s
+      - SERVICE_6379_CHECK_TIMEOUT=3s
+      - SERVICE_CHECK_DEREGISTER_AFTER=1m
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "12m"
+        max-file: "5"
+