Browse Source

Stack file inclusion

dev
root 4 years ago
parent
commit
dbe6f62fa2
  1. 3
      roles/lxc_swarm/tasks/deploy.yml
  2. 102
      stack.yaml

3
roles/lxc_swarm/tasks/deploy.yml

@ -15,8 +15,9 @@
unset MASTER_ADDR
mcontainer_addr=`ssh root@10.0.3.100 "docker ps|xargs -n1|grep -i NAMES -A 1|tail -1"`
MASTER_ADDR=`ssh -t root@10.0.3.100 "docker exec -it $mcontainer_addr ip a s|grep -i 10.0|head -1 2>/dev/null" 2>&1 |grep inet|awk '{print $2}'|cut -d "/" -f 1|tr -d ' '`
[ -z $MASTER_ADDR ] && echo "Node 1 hasn't yet been initialized" && exit 1
env MASTER_ADDR="${MASTER_ADDR}" docker stack deploy -c stack.yaml stack
docker service scale stack_bnode=1
env MASTER_ADDR="${MASTER_ADDR}" docker service scale stack_bnode=1
# sleep 30
args:
executable: /bin/bash

102
stack.yaml

@ -0,0 +1,102 @@
version: '3.4'
services:
# seed:
# image: colinmollenhour/mariadb-galera-swarm
# environment:
# - XTRABACKUP_PASSWORD_FILE=/run/secrets/xtrabackup_password
# - MYSQL_USER=user
# - MYSQL_PASSWORD_FILE=/run/secrets/mysql_password
# - MYSQL_DATABASE=database
# - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
# - NODE_ADDRESS=^10.0.*.*
# networks:
# - galera_network
# command: seed
# deploy:
# placement:
# # Services must run only on workers with one service per container
# constraints:
# - node.labels.node1 == true
# - node.role == worker
# volumes:
# - /var/lib/mysql:/var/lib/mysql
# secrets:
# - xtrabackup_password
# - mysql_password
# - mysql_root_password
anode:
image: colinmollenhour/mariadb-galera-swarm
# hostname:
environment:
- XTRABACKUP_PASSWORD_FILE=/run/secrets/xtrabackup_password
- NODE_ADDRESS=^10.0.*.*
- HEALTHY_WHILE_BOOTING=1
networks:
- galera_network
command: node tasks.anode,tasks.bnode
volumes:
- /var/lib/mysql:/var/lib/mysql
deploy:
# Replicated mode
mode: replicated
replicas: 1
# restart_policy:
# delay: 10s
# max_attempts: 10
# window: 60s
placement:
# Services must run only on workers with one service per container
#max_replicas_per_node: 1
constraints:
- node.labels.node1 == true
- node.role == worker
secrets:
- xtrabackup_password
bnode:
image: colinmollenhour/mariadb-galera-swarm
#hostname: bnode
environment:
- XTRABACKUP_PASSWORD_FILE=/run/secrets/xtrabackup_password
- NODE_ADDRESS=^10.0.*.*
- HEALTHY_WHILE_BOOTING=1
- MASTER_ADDR
networks:
- galera_network
command: node $MASTER_ADDR,tasks.bnode
volumes:
- /var/lib/mysql:/var/lib/mysql
deploy:
# Replicated mode
mode: replicated
replicas: 0
# restart_policy:
# delay: 10s
# max_attempts: 10
# window: 60s
placement:
# Services must run only on workers with one service per container
#max_replicas_per_node: 1
constraints:
- node.labels.node2 == true
- node.role == worker
depends_on:
- bnode
secrets:
- xtrabackup_password
#volumes:
# mysql-data:
# name: '{{.Service.Name}}-{{.Task.Slot}}-data'
# driver: local
networks:
galera_network:
secrets:
xtrabackup_password:
file: .secrets/xtrabackup_password
mysql_password:
file: .secrets/mysql_password
mysql_root_password:
file: .secrets/mysql_root_password
Loading…
Cancel
Save