Conditional deploy node

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.

any Idea? Thanks!

Why do you need to re-deploy it in node-1??

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.

2 Likes

Hi! thanks for reply.

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.

Thanks you!

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 .

For this don´t work me.

Regards.

I’m a bit lost. If you loose the manager, there would not be any new deploys of containers anyway. :confused:

Hi,

Is true, with only one manager not is possible . :frowning: sorry

Very much confused…How are containers there? I mean after loosing a manager,there is no chance of containers anyway.

don´t worry , not is possible this work :slight_smile: thanks very much