icflorescu/openshift-cartridge-mongodb

Support for username and password

Closed this issue · 6 comments

Hi. I am very new to OpenShift and was getting errors in their mongodb-2.4 cartridge so I am trying your 2.6 cartridge. It fixed my site so now it works. Thanks!

But, the default OpenShift mongodb cartridge sets itself up with a username and password by default which are populated in environment variables.

Is there a way to get a username and password on the database, and have it set up by default?

Or is a password unnecessary because of how OpenShift sandboxes gears?

Hi, Victor! I'm glad you find this cartridge useful!

Most people would use this cartridge for simple, non-critical projects in a free gear, and the free gears aren't accepting external connections anyway (except through rhc port-forward from an authenticated machine), so - to keep things simple - I'd say there's no real need for username/password.

Basically the only things that can connect to the MongoDB instance are:

  • your web application residing in the main gear (or in the same gear if you're not using scaling);
  • your development machine.

If you're thinking about a large / critical project, I'd suggest using a specialized MongoDB provider like MongoLab or Compose, and keep in mind that OpenShift will switch to a Docker-based architecture in a few months.

Thanks for the tip. I am currently just evaluating the platform. I don't
even know what Docker is so I guess I have my research cut out for me.

One more thing -- from my rhc ssh shell I can't use the mongo command
(bash: mongo: command not found), whereas I seem to recall that working
using the default mongodb cartridge. Is there just a configuration issue I
need to address?

On Fri, Feb 13, 2015 at 10:26 AM, Ionut-Cristian Florescu <
notifications@github.com> wrote:

If you're thinking about a large / critical project, I'd suggest using a
specialized MongoDB provider like MongoLab https://mongolab.com/ or
Compose https://www.compose.io/mongodb/, and keep in mind that
OpenShift will switch to a Docker-based architecture in a few months.


Reply to this email directly or view it on GitHub
#1 (comment)
.

A full MongoDB installation would take up lots of space, over 250 MB last time I checked, and if you're using a standard OpenShift cartridge this could become a problem. That's why I'm only keeping mongod in the cartridge - the bare minimum to run the server; that way you can use the entire cartridge storage space for your data (~1GB on the standard cartridge, I think).

To directly connect to the server MongoDB instance you'll have to use rhc port-forward (see more here), and then you can use mongo, RoboMongo or any MongoDB client as you would for a server running locally on your development machine. Just make sure to specify the forwarded port when you're connecting.

A quick notice for people using rhc port-forward to connect from their development machines: for now, MongoChef offers better support for MongoDB 3.x than RoboMongo.

@icflorescu What do you think about this tutorial for sharing a database across apps/gears:
https://blog.openshift.com/sharing-database-across-applications/

It seems like there is a way to connect to ports other than 80/8080 however I'm not seeing any mention of this in the cartridge building documentation