GithubHelp home page GithubHelp logo

Comments (3)

dottgonzo avatar dottgonzo commented on May 28, 2024 6

I'm happy to say that my stupid workaround, with mode global, works like expected. Maybe my bad English not helps, i will try to repeat what i can do to ensure to be able to use the global mode:

  1. you have your swarm running

  2. on only 1 node let's add a label like mariadb=true (for this example)

  3. let's add the constraint for the service, for example on the deploy section of docker compose :

      mode: global
      placement:
        constraints:
          - node.labels.mariadb == true
  1. now i deploy the stack and see that it starts only on the node labeled with mariadb=true, so this will became the master node

  2. after the master node start, we can add to the other nodes we want to use, the label mariadb=true, and the other instances will starts from that nodes, and they will join on cluster

from docker-mariadb-cluster.

toughIQ avatar toughIQ commented on May 28, 2024

I have been looking into this for quite some time. But I cant figure out a way to do it.
With mode global more than one instance would start at a time. So its pure luck, that we dont run into a race condition where more than one instance thinks its the first one and will go into bootstrap mode.
But since all tasks in a swarm are completely identical in configuration, there is no way of "hard coding" the bootstrap mode into just one of them.
Another idea was to start a single bootstrap service. And then point the "normal" cluster members to this service for bootstrapping. But this will result in a condition, were at failure a restarted task will look for this bootstrapping instance again, since by configuration its the only node it is aware of.
Afaik Swarm mode does its scheduling by trying to spread out workload evenly on the available nodes. At the beginning it tries to put one task of a service on each node. Which would result in an evenly spread out cluster over all nodes.
Using constraint flags doesnt help either, since swarm just supports labels tied to nodes and not to services.
When using Rancher for orchestrating a Docker Cluster, you could define constraints like: dont put on same node as container X or service Y. Docker Swarm does not offer such constraints yet.

from docker-mariadb-cluster.

toughIQ avatar toughIQ commented on May 28, 2024

I am happy that you found a pretty fine solution for this problem.
Will keep it in mind if I need to do such a setup one time.

Thanks, Chris

from docker-mariadb-cluster.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.