I have a swarm cluster of 6 worker nodes and 3 master nodes so a total of 9 nodes. I am having machines of different sizes in my swarm cluster. So there is a requirement that I need to deploy certain services (containers) on particular worker nodes as per the size of the node. I am aware we can have placement constraints in the docker-compose file and can specify the hostname.
Since I will be running 2 replicas of the service so swarm will create replicas on the same worker to which I have set the constraint. But I don't want the replicas to be running on the same worker node.
Can we have an option to specify multiple hostnames while setting the placement constraint? Please guide.
You can to combine some nodes by labels.
docker node update --label-add ssd=fat_machine hostname1
docker node update --label-add ssd=fat_machine hostname2
and define label in docker-compose
constraints: [node.labels.ssd == fat_machine]