Closed jri-sp closed 4 years ago
@jri-sp I'd like to give this PR a try, how do you run this? Is it possible to add this to the catalog somehow?
Hi @RonRademaker ,
I'm using my Docker image which is an automated build from my fork: https://hub.docker.com/r/jrisp/mongodb-conf/
I specify it by adding a new stack with a custom docker-compose.yml
and rancher-compose.yml
, for example:
docker-compose.yml
:
version: '2'
services:
mongo-config:
image: mongo:3.0
stdin_open: true
tty: true
command:
- --configsvr
labels:
io.rancher.container.pull_image: always
io.rancher.container.hostname_override: container_name
mongo-datavolume:
image: busybox
entrypoint:
- /bin/true
network_mode: none
volumes:
- /data/db
links:
- mongo-router:mongo-router
labels:
io.rancher.container.start_once: 'true'
io.rancher.container.hostname_override: container_name
mongo-router:
image: mongo:3.0
tty: true
links:
- mongo-config:mongo-config
volumes_from:
- mongo-scripts
command:
- /opt/rancher/bin/router.sh
labels:
io.rancher.sidekicks: mongo-scripts
io.rancher.container.hostname_override: container_name
mongo-scripts:
image: jrisp/mongodb-conf:v0.2.0
stdin_open: true
entrypoint:
- /bin/true
links:
- mongo-config:mongo-config
labels:
io.rancher.container.start_once: 'true'
io.rancher.container.hostname_override: container_name
io.rancher.container.pull_image: always
mongo-cluster:
image: mongo:3.0
environment:
MONGO_ROUTER_SERVICE_NAME: mongo-router
MONGO_SERVICE_NAME: mongo-cluster
REPLSET_NAME: rs0
entrypoint:
- /opt/rancher/bin/entrypoint.sh
links:
- mongo-router:mongo-router
volumes_from:
- mongo-datavolume
- mongo-base
command:
- --replSet
- rs0
labels:
io.rancher.sidekicks: mongo-base,mongo-datavolume
io.rancher.container.hostname_override: container_name
mongo-base:
image: jrisp/mongodb-conf:v0.2.0
stdin_open: true
entrypoint:
- /bin/true
links:
- mongo-router:mongo-router
labels:
io.rancher.container.start_once: 'true'
io.rancher.container.hostname_override: container_name
io.rancher.container.pull_image: always
rancher-compose.yml
:
version: '2'
services:
mongo-config:
scale: 3
start_on_create: true
mongo-datavolume:
scale: 4
start_on_create: true
mongo-router:
scale: 2
start_on_create: true
mongo-scripts:
scale: 2
start_on_create: true
mongo-cluster:
scale: 4
start_on_create: true
mongo-base:
scale: 4
start_on_create: true
Is this helps you ? Unfortunately, I don't know how to use the custom catalog..
Regards
Thanks! I'll give it a try
Very stale. Closing. Thanks! Please open a new PR if there is still a relevant change.
Hi @galal-hussein
First, I would like to thank you for your work on this. It really help me for my job.
I've just added a MongoDB router on your stack (with three MongoDB Config servers).
This is because your cluster out of the box can't be really used because if I just use a docker link between
mongo-cluster
and my apps, they can't choose where to write (the PRIMARY) and I've many apps in this case.What I've done: 1) A Mongo router entrypoint which format IPs from Rancher DNS with
giddyup
and runmongos
commands 2) Update yourconnect.sh
to use IP address instead of hostname when initiate the replicaset, because there was a mix between hostnames and IPs which cause problems when declaring them on mongo-router. I choose to use only IPs but it can be discussed. 3) Update yourconnect.sh
to add a function to add a Shard tomongo-router
config. I've added two environment variables for that. I don't know how to set this with the Rancher Configuration Options form from catalog andanswers.txt
4) Updatedocker-compose.yml
andrancher-compose.yml
files with the new containers and links. One thing that I'm not proud of ismongo-scripts
sidekick container which is the same asmongo-base
: it's a bit redundant. I don't know how to usemongo-base
as a sidekick container for bothmongo-router
andmongo-cluster
: Rancher shows an error when I'm doing that...I've a
mongodb-conf
container builded with my changes here if you want to test it: https://hub.docker.com/r/jrisp/mongodb-conf/For my part, I already use this in production environment. I can scale mongo shards or mongo routers easily upon my load.
I really just want to help, because for me this is a missing feature in your stack. I had to do it for my work so I just share it.
If you think that is not necessary, it'll be kind to say it to me and don't let this PR die in Github's abyss. If you think it's cool but it needs improvements, say it and I'll try to do it for you.
Hope this could help..
Best regards.