hi! I have this case:
One service with repliqued = 1 in swarmme with two nodes.
I need that this services is reploy in node-1, but if node-1 is off , need than this service go to node-2, but only in this case. is possible?
Im try with affinity and his don´t work.
You should strive to make your containers in such a way that they can be deployed in any worker node, or if you need the container to run in a host that has some configuration (such as logs, static routes to resources or similar) use labels when you deploy them.
Conditional deploy can be done using a script that first checks all the node states and creates unique service label sets for each service when they are redeployed. The tricky part is to catch the swarm events.
I have this problem, for i have few nodes. I only have one manager and one worker. In manager have services of infrastructure, (elastic, prometheus … ). I’m interes than node-1 (manager) only have this services, but at the same time if the manager is out, the services can deploy in node-2, at least for a short time.
I´m try use affinity with containers labels, but for my don´t work this.
review - Sorry, I’m very clueless. affinity don´t work for swarm mode , only for swarm standalone. I want mean than don´t work for versions docker > 1.12 .