Docker swarm: how to place app and db together?
up vote
2
down vote
favorite
I have stack with 2 services: Spring boot application and mongo database.
I want to deploy this stack to Docker Swarm (1 node in Germany, 1 in Finland and 1 in Estonia).
Currently Swarm schedules application to Germany cluster and Database to Finland, which means that every request goes from Germany to Finland.
Is this way how to force Swarm place all pieces of stack to single node ?
P.S. sticking to hostname is not a solution, because if node dies service is down.
My Stack.yml is:
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
networks:
- net
ports:
- "8080:8080"
depends_on:
- mongo
labels:
- ee.yadev.bootmongoapp
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
mongo:
image: mongo
networks:
- net
volumes:
- example-mongo:/data/db
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
networks:
net:
driver: overlay
volumes:
example-mongo:
external: true
docker docker-swarm docker-swarm-mode
add a comment |
up vote
2
down vote
favorite
I have stack with 2 services: Spring boot application and mongo database.
I want to deploy this stack to Docker Swarm (1 node in Germany, 1 in Finland and 1 in Estonia).
Currently Swarm schedules application to Germany cluster and Database to Finland, which means that every request goes from Germany to Finland.
Is this way how to force Swarm place all pieces of stack to single node ?
P.S. sticking to hostname is not a solution, because if node dies service is down.
My Stack.yml is:
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
networks:
- net
ports:
- "8080:8080"
depends_on:
- mongo
labels:
- ee.yadev.bootmongoapp
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
mongo:
image: mongo
networks:
- net
volumes:
- example-mongo:/data/db
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
networks:
net:
driver: overlay
volumes:
example-mongo:
external: true
docker docker-swarm docker-swarm-mode
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have stack with 2 services: Spring boot application and mongo database.
I want to deploy this stack to Docker Swarm (1 node in Germany, 1 in Finland and 1 in Estonia).
Currently Swarm schedules application to Germany cluster and Database to Finland, which means that every request goes from Germany to Finland.
Is this way how to force Swarm place all pieces of stack to single node ?
P.S. sticking to hostname is not a solution, because if node dies service is down.
My Stack.yml is:
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
networks:
- net
ports:
- "8080:8080"
depends_on:
- mongo
labels:
- ee.yadev.bootmongoapp
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
mongo:
image: mongo
networks:
- net
volumes:
- example-mongo:/data/db
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
networks:
net:
driver: overlay
volumes:
example-mongo:
external: true
docker docker-swarm docker-swarm-mode
I have stack with 2 services: Spring boot application and mongo database.
I want to deploy this stack to Docker Swarm (1 node in Germany, 1 in Finland and 1 in Estonia).
Currently Swarm schedules application to Germany cluster and Database to Finland, which means that every request goes from Germany to Finland.
Is this way how to force Swarm place all pieces of stack to single node ?
P.S. sticking to hostname is not a solution, because if node dies service is down.
My Stack.yml is:
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
networks:
- net
ports:
- "8080:8080"
depends_on:
- mongo
labels:
- ee.yadev.bootmongoapp
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
mongo:
image: mongo
networks:
- net
volumes:
- example-mongo:/data/db
deploy:
mode: replicated
replicas: 1
update_config:
parallelism: 1
delay: 10s
networks:
net:
driver: overlay
volumes:
example-mongo:
external: true
docker docker-swarm docker-swarm-mode
docker docker-swarm docker-swarm-mode
asked 7 hours ago
kyberorg
1551515
1551515
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
my first idea is to suggest you to use "placement constraints" and "labels":
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata
Thanks to them you can assign labels to nodes for each country and then modify your stack in order to force the apps to run on the same node.
docker node update --label-add country=Germany node-germany
docker node update --label-add country=Finland node-finland
--constraint node.labels.region==east
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
deploy:
placement:
constraints:
- country == Germany
mongo:
image: mongo
deploy:
placement:
constraints:
- country == Germany
Other useful links:
https://semaphoreci.com/community/tutorials/scheduling-services-on-a-docker-swarm-mode-cluster
https://container-solutions.com/using-binpack-with-docker-swarm/
I hope this can help you!
New contributor
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
my first idea is to suggest you to use "placement constraints" and "labels":
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata
Thanks to them you can assign labels to nodes for each country and then modify your stack in order to force the apps to run on the same node.
docker node update --label-add country=Germany node-germany
docker node update --label-add country=Finland node-finland
--constraint node.labels.region==east
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
deploy:
placement:
constraints:
- country == Germany
mongo:
image: mongo
deploy:
placement:
constraints:
- country == Germany
Other useful links:
https://semaphoreci.com/community/tutorials/scheduling-services-on-a-docker-swarm-mode-cluster
https://container-solutions.com/using-binpack-with-docker-swarm/
I hope this can help you!
New contributor
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
add a comment |
up vote
0
down vote
my first idea is to suggest you to use "placement constraints" and "labels":
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata
Thanks to them you can assign labels to nodes for each country and then modify your stack in order to force the apps to run on the same node.
docker node update --label-add country=Germany node-germany
docker node update --label-add country=Finland node-finland
--constraint node.labels.region==east
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
deploy:
placement:
constraints:
- country == Germany
mongo:
image: mongo
deploy:
placement:
constraints:
- country == Germany
Other useful links:
https://semaphoreci.com/community/tutorials/scheduling-services-on-a-docker-swarm-mode-cluster
https://container-solutions.com/using-binpack-with-docker-swarm/
I hope this can help you!
New contributor
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
my first idea is to suggest you to use "placement constraints" and "labels":
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata
Thanks to them you can assign labels to nodes for each country and then modify your stack in order to force the apps to run on the same node.
docker node update --label-add country=Germany node-germany
docker node update --label-add country=Finland node-finland
--constraint node.labels.region==east
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
deploy:
placement:
constraints:
- country == Germany
mongo:
image: mongo
deploy:
placement:
constraints:
- country == Germany
Other useful links:
https://semaphoreci.com/community/tutorials/scheduling-services-on-a-docker-swarm-mode-cluster
https://container-solutions.com/using-binpack-with-docker-swarm/
I hope this can help you!
New contributor
my first idea is to suggest you to use "placement constraints" and "labels":
https://docs.docker.com/engine/swarm/services/#placement-constraints
https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata
Thanks to them you can assign labels to nodes for each country and then modify your stack in order to force the apps to run on the same node.
docker node update --label-add country=Germany node-germany
docker node update --label-add country=Finland node-finland
--constraint node.labels.region==east
version: '3.3'
services:
app:
image: kyberorg/boot-mongo
deploy:
placement:
constraints:
- country == Germany
mongo:
image: mongo
deploy:
placement:
constraints:
- country == Germany
Other useful links:
https://semaphoreci.com/community/tutorials/scheduling-services-on-a-docker-swarm-mode-cluster
https://container-solutions.com/using-binpack-with-docker-swarm/
I hope this can help you!
New contributor
New contributor
answered 6 hours ago
giabar
1
1
New contributor
New contributor
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
add a comment |
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
Thanks for answer. Country labels are not what I'm actually looking for. Because if germal node is down, app is down as well. Binpack strategy is good from me. I attempted to add affinity to ENV vars.But neither affinity.service nor affinity.container succeeded.
– kyberorg
5 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371100%2fdocker-swarm-how-to-place-app-and-db-together%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown