Newsletters




MongoDB Atlas – Beyond the UI


Mongo Atlas—MongoDB's Database as a Service offering—has become increasingly central to MongoDBs commercial strategy. Since its launch in 2016, MongoDB has onboarded tens of thousands of customers to Atlas, and Atlas now represents almost two-thirds of MongoDB's revenue.

The success of Atlas mirrors the growing acceptance of cloud-based database solutions and the increasing acceptance of MongoDB as a general-purpose database solution.

It's very easy to provision an Atlas database cluster. Using the Atlas Web-based User Interface, we can create a high-capacity, highly available database cluster within minutes, even if we haven't previously used MongoDB.

However, despite the advantages of the Web UI, there are some circumstances in which an interactive deployment is not ideal.

In the modern world of orchestrated containerized applications—that is to say, the world of Docker and Kubernetes—DevOps professionals create deployment pipelines that allow for automated and repeatable deployments with little or no human intervention.

If your MongoDB implementation is running within the Kubernetes cluster, then we can use the MongoDB Kubernetes operator to automate the deployment. However, if the deployment depends on an Atlas database service, we need a way to automate that Atlas deployment.

MongoDB and its partners offer several automation solutions for Atlas. Firstly, the MongoDB Atlas CLI (Command Line Interface) allows an administrator to perform any operation that can be achieved using the Atlas UI. 

For instance, using the Atlas CLI, we can create clusters, modify the configuration of existing clusters, set network access rules, create/modify database users, and perform any other task that would otherwise require the UI.

Creating a complex database deployment using the CLI is undoubtedly more complicated than using the UI.  However, CLI commands can be reused and are self-documenting. Once we've established an initial set of CLI commands, we can parameterize them and reuse them in subsequent deployments—possibly including automated deployments.

While command-line scripts are convenient, they don't have robust error handling and conditional logic. We can use the MongoDB Atlas REST-based API to create more intelligent automation.

The API mirrors the commands available in the CLI—the CLI is actually a wrapper around the API calls. 

The use of CLI and APIs to configure databases like MongoDB is part of a movement toward "Infrastructure as Code" (IaC), in which machine-readable configuration files are used to provision services and resources. Ideally, an Infrastructure as Code solution utilizes a standard configuration format rather than relying on scripts and programs written in disparate languages.

Terraform from Hashicorp is one such IaC solution. In Terraform, configuration files define the final state of all resources—Kubernetes clusters, application services, databases, and so on. These configuration files can be applied to a target infrastructure or cloud, and the Terraform system will generate the low-level infrastructure to implement the system. As a result, Terraform configurations can rapidly and repeatedly deploy complex application stacks.

Terraform provides a MongoDB Atlas provider, which allows MongoDB Atlas clusters to be defined within Terraform deployments. For organizations that use Terraform to deploy various elements of the application stack, from Kubernetes clusters to microservice pods, the ability to define the MongoDB Atlas dependencies in the same configuration allows for the complete application deployment to be automated and replicated.

Terraform is popular because it provides cross-cloud compatibility, allowing deployments to be targeted at Google GCP, Amazon AWS, or Microsoft Azure. However, for those committed to Amazon, the AWS CloudFormation (CFN) solution is an Infrastructure as Code solution tightly tied to AWS. MongoDB has provided CFN templates allowing you to configure MongoDB Atlas services within CFN definitions. 

Modern DevOps practices require that entire application stacks can be built on demand from committed source code. The MongoDB Atlas CLI, API, and the Terraform and CloudFormation MongoDB Atlas templates allow Atlas to be part of these modern DevOps pipelines.


Sponsors