Docker Community Forums

Share and learn in the Docker community.

Conditional deploy node

swarm

(Flaco0) #1

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!


(Ove "Lime" Lindström) #2

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.


(Flaco0) #3

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!


(Flaco0) #4

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.


(Ove "Lime" Lindström) #5

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


(Flaco0) #6

Hi,

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


#7

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


(Flaco0) #8

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