Charmed MongoDB How-To | Manage client connections

How to manage client connections

Integrations (formerly “relations”) are connections between two applications with compatible endpoints. These connections simplify the creation and management of users, passwords, and other shared data.

Summary


Create a client connection to a bare replica set

To create a client connection to a replica set, simply integrate your client application with a Charmed MongoDB application running in replication mode.

If you do not have a client application that implements this interface, you can use the data-integrator charm.

To integrate mongodb with a client application, run:

juju integrate mongodb-k8s <application>

Remove client connection

To remove a client connection and the user associated with it:

juju remove-relation mongodb-k8s <application>

Create a client connection to a sharded cluster

To create a client connection to a sharded cluster, you must use the Charmed Mongos-K8s router.

mongos is a subordinate charm and must have a host charm. If you do not have a suitable host application, you may use the data-integrator charm.

To deploy mongos and data-integrator, run:

juju deploy mongos-k8s
juju deploy data-integrator [necessary options]

Wait for mongos’s status to be idle, then integrate it with data-integrator:

juju integrate mongos-k8s data-integrator

Next, integrate the mongos charm to a Charmed MongoDB application running as a config-server:

juju integrate config-server mongos-k8s

Remove client connection

To remove a client connection to a sharded cluster:

juju remove-relation config-server mongos-k8s

Rotate the client password

To rotate client passwords, the integration should be removed and integrated again:

juju remove-relation <application> mongodb
juju integrate <application> mongodb

This process will generate a new user and password for the application. It works for both replica sets and sharded cluster client connections.

Internal operator user

The operator (i.e. admin) user is used internally by the Charmed MongoDB Operator. To rotate its password, use the set-password action.

To set a specific password for the operator user, run:

juju run mongodb-k8s/leader set-password password=<password>

To randomly generate a password for the operator user, run:

juju run mongodb-k8s/leader set-password