The Charmed Mongos K8s operator deploys and operates mongos instances on Kubernetes.
mongos is a router for connecting client applications to a sharded MongoDB K8s clusters. It is the only way to access a sharded MongoDB cluster from the client perspective.
To deploy a sharded MongoDB cluster, see our charmed solution for MongoDB K8s.
For information about how to deploy, integrate, and manage this charm, see the Official Charmed Mongos documentation.
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 guidance about setting up your environment, see the Charmed MongoDB K8s tutorial.
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
--trustflag 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 application running as config-server:
juju integrate mongos-k8s data-integrator
juju integrate config-server mongos-k8s
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.
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>
For more information about TLS in sharded clusters, see the Charmed MongoDB documentation for enabling security in sharded clusters
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=nodeportThis 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=noneTo 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 about operating MongoDB sharded clusters and replica sets in the Charmed MongoDB K8s documentation
- Check the charm's GitHub repository
- Learn more about the
mongosrouter in the upstreammongosdocumentation
Charmed Mongos K8s is an open source project that warmly welcomes community contributions, suggestions, fixes, and constructive feedback.
- Check our Code of Conduct
- Raise software issues or feature requests on GitHub
- Report security issues through LaunchPad.
- Meet the community and chat with us on Matrix
- Contribute to the code