Create the MongoDB Users

You must create the admin and event loader users.

Procedure

  1. Create a Kubernetes secret for an admin user password where password is the password.
    kubectl create secret generic mtx-admin-password --from-literal="password=password" -n mongodb
    kubectl create secret generic mtx-user-password --from-literal="password=password" -n mongodb
  2. Create an admin user with the mtx-admin-password Secret. Add the following to the admin-user.yaml file:
    apiVersion: mongodb.com/v1
    kind: MongoDBUser
    metadata:
      name: mtx-admin-user
      namespace: mongodb
    spec:
      passwordSecretKeyRef:
        name: mtx-admin-password
        key: password
      username: MtxAdmin
      db: admin
      mongodbResourceRef:
        name: mtx
      roles:
        - db: admin
          name: root
  3. Create an Event Loader user with the mtx-user-password Secret. Add the following to the loader-user.yaml file:
    apiVersion: mongodb.com/v1
    kind: MongoDBUser
    metadata:
      name: mtx-event-loader-user
      namespace: mongodb
    spec:
      passwordSecretKeyRef:
        name: mtx-user-password
        key: password
      username: MtxEventLoader
      db: MtxEventDatabase
      mongodbResourceRef:
        name: mtx
      roles:
        - db: MtxEventDatabase
          name: dbAdmin
        - db: MtxEventDatabase
          name: readWrite
        - db: admin
          name: root