I got three nodes in my swarm, one manager and two workers (worker1 and worker2). I have a couple of services which preferably is running on the first worker node (worker1), however when this node goes down I wish it to start running on the second worker node.
From what I've gathered I could put a constraint like this.
placement:
constraints:
- node.hostname==worker1
This however forces the service to be run on worker1 and when that node goes down the service will simply go down.
I could also do this
placement:
constraints:
- node.role==worker
This restricts the service to either one of the worker nodes but doesn't prioritize worker1 as I want to. Is there a way to prioritize the service to a specific node rather than putting a constraint?