Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy in swarm with portainer #4

Open
devMls opened this issue Nov 30, 2021 · 1 comment
Open

deploy in swarm with portainer #4

devMls opened this issue Nov 30, 2021 · 1 comment

Comments

@devMls
Copy link

devMls commented Nov 30, 2021

Hi

at first, this is just the thing that i was looking for, amazing work.

i am trying to deploy with portainer in a 3 nodes docker swarm this solution, i edit the yaml file but i have some errors, i can fix the depends_on but with the external files, i don't know where to push it. i am using deploy stack option.

i have this error:

open /data/compose/24/nginx-galera.conf: no such file or directory

and three questions:

  • can i configure all mysql params with the enviroment variables? or i need others files?
  • why do you choose nginx over proxysql or maxscale solutions?
  • how can i configure mysql backups?
version: "3.8"
services:
  db01:
    image: ustcweizhou/mariadb-cluster:latest
    hostname: db01
    networks:
        overlay-db:
    volumes:
      - ${DATA_DIR}/$PROJECT/db01:/var/lib/mysql
    healthcheck:
        test: ["CMD", "mysqladmin", "-uroot", "-pcloudstack", "ping"]
        interval: 10s
        timeout: 10s
        retries: 60
        start_period: 10s
    environment:
      - NODE_NAME=db01
      - CLUSTER_ADDRESS=gcomm://db01,db02,db03
      - DB_ROOT_PASSWORD=cloudstack
      - DB_MARIABACKUP_PASSWORD=cloudstack
    deploy:
      placement:
        constraints:
          - "node.labels.node==docker1"
  db02:
    image: ustcweizhou/mariadb-cluster:latest
    hostname: db02
    depends_on:
      - db01
    networks:
        overlay-db:
    volumes:
      - ${DATA_DIR}/$PROJECT/db02:/var/lib/mysql
    healthcheck:
        test: ["CMD", "mysqladmin", "-uroot", "-pcloudstack", "ping"]
        interval: 10s
        timeout: 10s
        retries: 60
        start_period: 10s
    environment:
      - NODE_NAME=db02
      - CLUSTER_ADDRESS=gcomm://db01,db02,db03
      - DB_ROOT_PASSWORD=cloudstack
      - DB_MARIABACKUP_PASSWORD=cloudstack
    deploy:
      placement:
        constraints:
          - "node.labels.node==docker2"    
  db03:
    image: ustcweizhou/mariadb-cluster:latest
    hostname: db03
    depends_on:
      - db01 
      - db02
    networks:
        overlay-db:
    volumes:
      - ${DATA_DIR}/$PROJECT/db03:/var/lib/mysql
    environment:
      - NODE_NAME=db03
      - CLUSTER_ADDRESS=gcomm://db01,db02,db03
      - DB_ROOT_PASSWORD=cloudstack
      - DB_MARIABACKUP_PASSWORD=cloudstack
    deploy:
      placement:
        constraints:
          - "node.labels.node==docker3"
  dbvip:
    image: nginx
    hostname: dbvip
    networks:
        overlay-db:
    ports:
        - "13306:3306"
    deploy:
      restart_policy:
        condition: on-failure
    configs:
        - source: nginx-galera
          target: /etc/nginx/nginx.conf
    depends_on:
      - db01

configs:
    nginx-galera:
        file: ./nginx-galera.conf
        
networks:
    overlay-db:
        driver: overlay
        attachable: true
        ipam:
            driver: default
            config:
                - subnet: 192.168.10.0/24
@weizhouapache
Copy link
Contributor

@devMls
thanks for raising this issue.

I have not verified yaml by docker swarm in the past 2 years. so there might be some bugs.
could you please create a pull request if you have fixed some issues you faced ?

If this docker image does not fit you want, you can modify the conf file or init.sh and rebuild the docker image. for example

  1. change the conf in my.cnf or create a conf file in conf/ (they will be copied when you rebuild the docker image)
  2. replace nginx with proxysql in yaml
  3. create a script for backup and copy it to docker image (see init.sh)

hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants