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

can't use mode global #7

Open
dottgonzo opened this issue Sep 4, 2017 · 3 comments
Open

can't use mode global #7

dottgonzo opened this issue Sep 4, 2017 · 3 comments

Comments

@dottgonzo
Copy link

Hi,
after some days spent on docker swarm, i'm happy to not have persistent volumes and to see that with many replicas all works good. There is another issue that could cause loosing data on cluster. If i need to boot first 1 replica, and then scale, i can't set global mode in docker swarm (because it start all the replicas contemporary), and with the replicated mode is possible that all the replicas are on the same node, so shutting down the node will delete everything.
The only one solution (not tested), is to enable global mode, but costrain the service to run on node with certain label and initially set it only on one node, and then adding that label to more nodes. The best is to be able to start all the replicas together. Is possible to fix this issue?

@toughIQ
Copy link
Owner

toughIQ commented Sep 4, 2017

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.

@dottgonzo
Copy link
Author

dottgonzo commented Sep 4, 2017

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

@toughIQ
Copy link
Owner

toughIQ commented Sep 5, 2017

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

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