Charmed Mongos K8s documentation

Charmed Mongos K8s documentation

The Charmed Mongos K8s operator deploys and operates mongos instances on Kubernetes.

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.

To deploy a sharded MongoDB cluster, please see our Charmed MongoDB K8s operator.

Summary


Get started

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

You’ll need a Juju environment and a MongoDB K8s application deployed as a sharded cluster. For more guidance, see the Charmed MongoDB K8s deployment guide.

Deploy and integrate

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

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

The --trust flag is necessary to grant the application access to the Kubernetes cluster.

To deploy mongos-k8s and data-integrator, run:

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

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

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

Retrieve the URI

In order to access the integrated database, you will need the mongos-k8s 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.

Enable TLS encryption

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

juju integrate mongos-k8s <tls-application>

<tls-application> must be the same TLS application that the sharded MongoDB cluster is integrated to.

For more information about TLS in sharded clusters, see the Charmed MongoDB K8s documentation

External connections

If you would like to connect the sharded MongoDB K8s cluster outside of Juju, this is possible with the configuration expose-external in the mongos-k8s charm.

Simply configure the charm to use nodeport:

 juju config mongos-k8s expose-external=nodeport

This will make the mongos router accessible outside of Juju and will provide you access to the cluster. You will now see that all of your client URIs have been updated.

For example run:

juju run data-integrator get-credentials

You will see that the URI has changed.

To reconfigure the charm to have internal access only, run:

 juju config mongos-k8s expose-external=none

Remove the connection

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

juju remove-relation config-server mongos-k8s

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

Learn more

Project and community

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

License

The Charmed Mongos Operator is free software, distributed under the Apache Software License, version 2.0. It installs, operates, and depends on MongoDB Community Version, which is licensed under the Server Side Public License (SSPL)

MongoDB is a trademark or registered trademark of MongoDB, Inc. Other trademarks are property of their respective owners.

Navigation

Navigation
Level Path Navlink
1 h-minor-upgrade Perform a minor upgrade
1 r-release-notes Release Notes
2 r-revision-17 Revision 17

Redirects

Mapping table
Path Location