swarm example#482
Conversation
d9c9729 to
0db0644
Compare
|
@nowheresly Thanks for the PR! We already have docker swarm example here. https://github.com/sorintlab/stolon/tree/master/examples/docker contributed by @ihcsim . I'm not sure how to proceed, is your example very different from the current one? |
|
Thanks for the reply. |
|
@nowheresly You can just remove my outdated example in your PR. |
|
Based on the comment of @ihcsim, I just added a commit to remove the previous swarm example. |
| # Copy binaries to Dockerfile image directories | ||
| declare -a DOCKERFILE_PATHS | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker ${BASEDIR}/examples/docker) | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker ${BASEDIR}/examples/swarm/image/docker ${BASEDIR}/examples/docker) |
There was a problem hiding this comment.
${BASEDIR}/examples/docker is removed, right?
There was a problem hiding this comment.
Yes, you're right. PR adapted. Thanks!
| @@ -0,0 +1,9 @@ | |||
| FROM postgres:${PGVERSION} | |||
There was a problem hiding this comment.
Isn't this template the same as the one in examples/kubernetes/image?
There was a problem hiding this comment.
Yes indeed. The content of both examples/kubernetes/image and examples/swarm/image are the same. My goal with this PR was to update the swarm example base on the kubernetes example. So I chose to use the same docker images for both examples.
There was a problem hiding this comment.
@nowheresly I'd like to avoid maintaining multiple set of identical files. I think we could remove these files and update the documentation to point to the examples/kubernetes/image.
| @@ -0,0 +1,20 @@ | |||
| ifndef PGVERSION | |||
There was a problem hiding this comment.
Isn't this Makefile the same as the one in examples/kubernetes/image?
There was a problem hiding this comment.
same reply as above
|
Thanks @ihcsim for your review! |
|
@sgotti This PR LGTM. |
| @@ -0,0 +1,9 @@ | |||
| FROM postgres:${PGVERSION} | |||
There was a problem hiding this comment.
@nowheresly I'd like to avoid maintaining multiple set of identical files. I think we could remove these files and update the documentation to point to the examples/kubernetes/image.
| /gopath/ | ||
| /release/ | ||
|
|
||
| .idea/ No newline at end of file |
There was a problem hiding this comment.
Don't add changes to .gitignore in this PR.
There was a problem hiding this comment.
Sure, this can be done in another PR
| # Copy binaries to Dockerfile image directories | ||
| declare -a DOCKERFILE_PATHS | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker ${BASEDIR}/examples/docker) | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker ${BASEDIR}/examples/swarm/image/docker |
There was a problem hiding this comment.
Since I'd like to keep only one image let's remove this.
|
|
||
| volumes: | ||
| pgkeeper1: | ||
| driver: local |
There was a problem hiding this comment.
Does using the local volume plugin will create some problems since on multiple node cluster since the keeper cannot be started on another node than the one where the volume has been created? Perhaps some notes to change this to a real persistent volume will be good.
There was a problem hiding this comment.
You're right, this section deserves probably more explanations.
Out of the box, only the local driver is available with docker swarm. That's the reason why this swarm example is based on the local driver.
I specifically chose to provide different names for volumes of keeper1 and keeper2 so that we can't have any volume mismatch if keeper1 and keeper2 are deployed on the same node of the swarm.
Nevertheless, IMHO, it makes no sense to deploy all keepers on the same node. So I would recommend to set some constraints on both keepers so that each node would have its own keeper. Here is an example of a configuration where keeper1 will be deployed only on a node whose nodename label is equal to node1:
keeper1:
deploy:
placement:
constraints: [node.labels.nodename == node1]
...
In case each keeper is deployed on its own node, a node failure should not prevent the cluster to remain in function.
I'm not sure if my explanations are clear to you. I would propose to add a comment in the README to explain this approach. @sgotti What do you think?
Of course, if a specific docker volume plugin is available that could enable to share volumes between nodes, the volume section of the docker-compose-pg.yml would have to be adapted accordingly to leverage this plugin and there's no need to set any constraints.
There was a problem hiding this comment.
@nowheresly Your explanation is right and I agree with you. A comment in the README will be great!
There was a problem hiding this comment.
Thanks for the review
There was a problem hiding this comment.
@sgotti I updated the README to explain how to set labels on each node and how to set constraints on each keeper. Hopefully, it should make sense to swarm users.
3476b71 to
5d5e13b
Compare
| # Copy binaries to Dockerfile image directories | ||
| declare -a DOCKERFILE_PATHS | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker ${BASEDIR}/examples/docker) | ||
| DOCKERFILE_PATHS=(${BASEDIR}/examples/kubernetes/image/docker |
There was a problem hiding this comment.
There's a missing closing bracket that is breaking the build
There was a problem hiding this comment.
Indeed, sorry for that!
|
@nowheresly LGTM. Merging. Thanks! |
Hi @sgotti
I was looking for a solution for postgres HA inside docker. So I decided to evaluate your project and played a little bit with your very well documented kubernetes example.
At the end, I was able to create a simple swarm version based on the kubernetes example.
So in case you could be interested in reviewing this swarm example, I would really appreciate to get your feedback.