Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting our team. We will be in touch shortly.Close

  1. Blog
  2. Article

Michelle Anne Tabirao
on 31 October 2023


Containers are a lightweight, portable, and consistent way to package applications and their dependencies. Containers provide an isolated environment, ensuring an application runs reliably across different environments. Enterprises and tech-savvy individuals are using container technologies because of their benefits. However,  container orchestration tools have become necessary to manage clusters with the rise in container usage.

Kubernetes, or k8s for short, is the most known container orchestrator and has grown into a feature-rich cloud-native platform. Kubernetes helps manage the lifecycle of containers, particularly in large, dynamic environments. It automates containerised workloads and services’ deployment, networking, scaling, and availability. Running containers – lightweight and usually ephemeral by nature – in small numbers is easy to do manually. However, managing them at scale in production environments can be a significant challenge without a container orchestration platform’s automation.

On the database front, organisations want to build and run scalable database applications in public, private and hybrid environments. This is why containerised databases like MongoDB can run in Kubernetes and benefit from portability, helping teams minimise vendor lock-in, get DevOps friendliness, scalability and cost-effectiveness.

Why run MongoDB on Kubernetes?

Running MongoDB on Kubernetes can be complex yet valuable, as it allows you to containerise and orchestrate MongoDB instances for scalability, resilience, and easier management. Here are some of the benefits: 

Scalability: Kubernetes makes it easier to scale MongoDB horizontally by adding or removing replicas of your database instances. This allows you to dynamically handle increased workloads and traffic as your application grows or as usage spikes.

High availability: Kubernetes provides features like replica sets and StatefulSets that ensure high availability for your MongoDB instances. In case of node failures, Kubernetes can automatically reschedule pods to maintain the desired number of replicas, helping to prevent downtime.

Orchestration: Kubernetes abstracts the underlying infrastructure, making managing and orchestrating your MongoDB deployment easier. In declarative configuration files, you can define your MongoDB resources, including pods, services, and storage.

Running MongoDB in Kubernetes can be very beneficial, but what exactly do you need to have a production-ready database running in Kubernetes? There can be multiple considerations besides those listed above, like security, deployment readiness, backup and restore, monitoring, and more.

Ubuntu as your host for MongoDB on Kubernetes

Canonical is currently maintaining a project called Charmed MongoDB, a K8s operator that contains code that takes over automated tasks to manage MongoDB hosted in Ubuntu. The K8s operator is also called a K8s charm, a business logic encapsulated in reusable software packages that automate every aspect of an application’s life, in this case, for MongoDB. 

The operator is based on Juju, an open source orchestration engine for software operators that enables the deployment, integration and lifecycle management of applications at any scale on any infrastructure.

To support applications running in Kubernetes, Canonical also maintains two other CNCF-certified Kubernetes distributions: Charmed Kubernetes and MicroK8s, which help simplify and accelerate the deployment of Kubernetes.

Get started

The Charmed MongoDB K8s Operator delivers automated operations management from day 0 to day 2 for MongoDB. Charmed MongoDB is a continuously developing project; we constantly offer richer features over time. 

To get started, you must have the environment: the Ubuntu OS, a minimum set of CPU, storage and RAM. You must also be familiar with basic terminal commands and MongoDB concepts such as replication and users. 

Afterwards, you need to set up your environment using Microk8s and Juju.

You can then use Charmed MongoDB to manage the following operations:

  • Deploy MongoDB using a single command.
  • Access the admin database directly.
  • Add high availability with replication.
  • Change the admin password.
  • Automatically create MongoDB users via Juju relations.
  • Enable secure communications with TLS.

Learn to use Charmed MongoDB (K8s operator) in your machine.

Conclusion

Running database clusters in public, private and hybrid environments provides multiple benefits. Kubernetes provides the additional advantages of portability, reduced vendor lock-in, DevOps friendliness, scalability and cost-effectiveness.

While there are many advantages to running MongoDB in Kubernetes, it’s important to note that managing a distributed database in a containerised environment comes with its challenges, and careful planning, monitoring, and optimisation are required for a successful deployment. Additionally, it helps to stay up-to-date with best practices and evolving technologies to make the most of this approach.

Canonical offers security patching, support, advisory and managed services for databases like MongoDB so you can seamlessly deploy and run your database in Kubernetes. Contact us to learn more.

Trademark Notice

“MongoDB” is a trademark or registered trademark of MongoDB Inc. Other trademarks are property of their respective owners. Charmed MongoDB is not sponsored, endorsed, or affiliated with MongoDB, Inc.

Related posts


Canonical
26 March 2024

Charmed MongoDB enters general availability

Canonical announcements Article

Charmed MongoDB, an enterprise solution for MongoDB® that comes with advanced automation features, multi-cloud capabilities and comprehensive support. ...


victoriaantipova
14 March 2024

Join the Canonical Data and AI team at Data Innovation Summit 2024

AI Data Platform

Join Canonical Data and AI team at Data Innovation Summit 2024 ...


Michelle Anne Tabirao
6 December 2023

Charmed MongoDB: the operator you need for managing your document database

Data Platform Article

Charmed MongoDB primary mission is to simplify the MongoDB experience so it can be an operated database powerhouse. ...