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
You can usebinpackdeployment strategy. Docker will do it's best to deploy all the services to single node
– WildDev
Nov 20 at 18:59
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 Nov 19 at 8:50
kyberorg
1551515
1551515
You can usebinpackdeployment strategy. Docker will do it's best to deploy all the services to single node
– WildDev
Nov 20 at 18:59
add a comment |
You can usebinpackdeployment strategy. Docker will do it's best to deploy all the services to single node
– WildDev
Nov 20 at 18:59
You can use
binpack deployment strategy. Docker will do it's best to deploy all the services to single node– WildDev
Nov 20 at 18:59
You can use
binpack deployment strategy. Docker will do it's best to deploy all the services to single node– WildDev
Nov 20 at 18:59
add a comment |
3 Answers
3
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!
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
Nov 19 at 10:50
add a comment |
up vote
0
down vote
What you are looking for is something like POD in kubernetes where co-location of containers is possible. AFAIK, this is currently not available on docker.
You can have a look at this repo and see if it is useful: https://github.com/rycus86/podlike
It's an attempt to bring the concept of pods to docker.
edit: On a side note, if the app and db are so tightly coupled, it makes sense that both are part of the same container.
add a comment |
up vote
0
down vote
The architecture of Swarm is one that you usually want a single swarm in the same region due to the latency of managers. Typically a swarm is "single region, multiple availability zones" (datacenters close to each other, in the same city usually.)
I also can't think of a way where you can use either constraints and/or placement preferences to have the two containers together in one datacenter, and then managers move them to the same 2nd datacenter if the first is down.
Podlike, like giabar mentioned, is an option but doesn't solve your "single swarm across multiple regions" design challenge.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
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!
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
Nov 19 at 10:50
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!
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
Nov 19 at 10:50
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!
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!
answered Nov 19 at 9:36
giabar
1
1
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
Nov 19 at 10:50
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
Nov 19 at 10:50
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
Nov 19 at 10:50
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
Nov 19 at 10:50
add a comment |
up vote
0
down vote
What you are looking for is something like POD in kubernetes where co-location of containers is possible. AFAIK, this is currently not available on docker.
You can have a look at this repo and see if it is useful: https://github.com/rycus86/podlike
It's an attempt to bring the concept of pods to docker.
edit: On a side note, if the app and db are so tightly coupled, it makes sense that both are part of the same container.
add a comment |
up vote
0
down vote
What you are looking for is something like POD in kubernetes where co-location of containers is possible. AFAIK, this is currently not available on docker.
You can have a look at this repo and see if it is useful: https://github.com/rycus86/podlike
It's an attempt to bring the concept of pods to docker.
edit: On a side note, if the app and db are so tightly coupled, it makes sense that both are part of the same container.
add a comment |
up vote
0
down vote
up vote
0
down vote
What you are looking for is something like POD in kubernetes where co-location of containers is possible. AFAIK, this is currently not available on docker.
You can have a look at this repo and see if it is useful: https://github.com/rycus86/podlike
It's an attempt to bring the concept of pods to docker.
edit: On a side note, if the app and db are so tightly coupled, it makes sense that both are part of the same container.
What you are looking for is something like POD in kubernetes where co-location of containers is possible. AFAIK, this is currently not available on docker.
You can have a look at this repo and see if it is useful: https://github.com/rycus86/podlike
It's an attempt to bring the concept of pods to docker.
edit: On a side note, if the app and db are so tightly coupled, it makes sense that both are part of the same container.
edited Nov 20 at 18:14
answered Nov 20 at 18:08
vimal-k
383
383
add a comment |
add a comment |
up vote
0
down vote
The architecture of Swarm is one that you usually want a single swarm in the same region due to the latency of managers. Typically a swarm is "single region, multiple availability zones" (datacenters close to each other, in the same city usually.)
I also can't think of a way where you can use either constraints and/or placement preferences to have the two containers together in one datacenter, and then managers move them to the same 2nd datacenter if the first is down.
Podlike, like giabar mentioned, is an option but doesn't solve your "single swarm across multiple regions" design challenge.
add a comment |
up vote
0
down vote
The architecture of Swarm is one that you usually want a single swarm in the same region due to the latency of managers. Typically a swarm is "single region, multiple availability zones" (datacenters close to each other, in the same city usually.)
I also can't think of a way where you can use either constraints and/or placement preferences to have the two containers together in one datacenter, and then managers move them to the same 2nd datacenter if the first is down.
Podlike, like giabar mentioned, is an option but doesn't solve your "single swarm across multiple regions" design challenge.
add a comment |
up vote
0
down vote
up vote
0
down vote
The architecture of Swarm is one that you usually want a single swarm in the same region due to the latency of managers. Typically a swarm is "single region, multiple availability zones" (datacenters close to each other, in the same city usually.)
I also can't think of a way where you can use either constraints and/or placement preferences to have the two containers together in one datacenter, and then managers move them to the same 2nd datacenter if the first is down.
Podlike, like giabar mentioned, is an option but doesn't solve your "single swarm across multiple regions" design challenge.
The architecture of Swarm is one that you usually want a single swarm in the same region due to the latency of managers. Typically a swarm is "single region, multiple availability zones" (datacenters close to each other, in the same city usually.)
I also can't think of a way where you can use either constraints and/or placement preferences to have the two containers together in one datacenter, and then managers move them to the same 2nd datacenter if the first is down.
Podlike, like giabar mentioned, is an option but doesn't solve your "single swarm across multiple regions" design challenge.
answered Nov 20 at 19:02
Bret Fisher
3,07611321
3,07611321
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
You can use
binpackdeployment strategy. Docker will do it's best to deploy all the services to single node– WildDev
Nov 20 at 18:59