Setup Database and Tables on creation

mongodb allows you to add setup scripts to docker-entrypoint-initdb.d to create initial databases / tables. They also support the following environment variables for setting up users / databases:

  MONGO_INITDB_ROOT_USERNAME
  MONGO_INITDB_ROOT_PASSWORD
  MONGO_INITDB_USERNAME
  MONGO_INITDB_PASSWORD
  MONGO_INITDB_DATABASE

Is it possible to specify this in the MongoDB operator?

1 Like

Hello @jml5qh ,

we do not support it for now in the Operator. It is possible to perform the same operations with you CICD pipeline or side tools.
Our focus is to provision the infrastructure and MongoDB itself, without going into the database.

If there is a hard requirement or blocker please let us know.

1 Like

I noticed there are references to MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD, MONGO_INITDB_DATABASE, and docker-entrypoint-initdb.d in percona-server-mongodb-operator/ps-entry.sh at main · percona/percona-server-mongodb-operator · GitHub.

I was able to create a root user by adding MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD to my user secrets file, but I’m still looking into picking up the docker-entrypoint-initdb.d directory. Am I going about this wrong? Is this not supported?

1 Like

Hi, i am also looking for a way to setup the initdb script. Any solution yet?

1 Like

No I ended up going with the Bitnami Helm chart

1 Like