Skip to content

canonical/mongos-operator

Repository files navigation

Charmed Mongos operator

Charmhub Release to 6/edge Tests

Overview

The Charmed Mongos operator deploys and operates mongos instances on both physical and virtual machines, along with a wide range of cloud and cloud-like environments.

mongos is a router for connecting client applications to a sharded MongoDB clusters. It is the only way to access a sharded MongoDB cluster from the client perspective.

It acts as a subordinate charmed operator and is meant to act as a proxy to a sharded MongoDB cluster. To deploy a sharded MongoDB cluster, please see our Charmed solution for MongoDB.

For information about how to deploy, integrate, and manage this charm, see the Official Charmed Mongos documentation.

Get started

The following steps will guide you through briefly creating a client connection to a sharded MongoDB cluster via mongos.

You'll need a Juju environment and a MongoDB application deployed as a sharded cluster. For guidance about setting up your environment, see the Charmed MongoDB tutorial for sharded clusters.

Deploy

To deploy a MongoDB sharded cluster with one shard, run:

juju deploy mongodb --config role="config-server" config-server
juju deploy mongodb --config role="shard" shard0

For more information about deploying a MongoDB sharded cluster, see the tutorial

To deploy mongos and data-integrator, run:

juju deploy mongos
juju deploy data-integrator --config database-name=<name>

Integrate

When the status of the mongos application becomes idle, integrate mongos with data-integrator and with the mongodb application running as config-server:

juju integrate mongos data-integrator
juju integrate config-server mongos

Access the database

In order to access the integrated database, you will need the mongos URI. To retrieve this, run the following command:

juju run data-integrator/leader get-credentials

You will find the URI under the field uris in the output.

For more information about accessing the database, see the Charmed MongoDB documentation for accessing a client database.

Enable TLS

If the sharded MongoDB cluster has TLS enabled, mongos must also enable TLS. Enable it by integrating mongos with a TLS application:

juju integrate mongos <tls-application>

For more information about TLS in sharded clusters, see the Charmed MongoDB documentation for enabling security in sharded clusters

Remove mongos

To remove a mongos connection to the sharded cluster, run:

juju remove-relation config-server mongos

Whenmongos is removed from the sharded cluster, the client is removed as well.

Learn more

Project and community

Charmed Mongos is an open source project that warmly welcomes community contributions, suggestions, fixes, and constructive feedback.