How to order and manage a database via API

Find out how to order and manage your Public Cloud managed database service using the OVHcloud API

Last updated September 3rd, 2021

Objective

Public Cloud managed databases allow you to focus on building and deploying cloud applications while OVHcloud takes care of the database infrastructure and maintenance.

This guide explains how to order a MongoDB instance of a Public Cloud managed database service using the OVHcloud API.

Requirements

Instructions

Step 1: Gather the set of required parameters

In order to create a database service, you will need to specify at minimum:

  • an engine, and its version (e.g. "MongoDB v4.4")
  • the plan (e.g. "business")
  • the nodes of the cluster (e.g. "3 nodes with 4 cores, 15 GiB memory, 100 GiB disk")

List the capabilities

The capabilities endpoint lists the allowed values for the engine, plan, and flavor the service knows about.

The call returns an object listing allowed values for:

  • the various engines, with the various versions for each engine
  • the plans
  • and the flavors

Get the availability

The availability endpoint lists what combination of parameters the service allows. For example, a MongoDB Essential plan currently allows clusters with a single node, whereas Business services allow clusters of 3 to 8 nodes. You should decide what set of parameters among that list best fit your needs.

The call returns an array listing the available set of parameters. Each entry in this array lists (among other data): an engine, a version, a plan, a flavor, a region, if it supports public or private networking, a minimum number of nodes and a maximum number of nodes.

Step 2: Create a MongoDB database service

By creating a cluster, you will be billed accordingly.

Use this endpoint to create a new database cluster:

  • description: A human-readable description for the service you wish to create
  • plan: the desired plan for the service
  • version: the MongoDB version you want to use
  • nodesPattern: specify the flavor and region, and the number of nodes you want to use
  • nodeslist: Leave this parameter undefined. It is another way to specify the list of nodes your cluster uses. As of today, multi-region and flavor-heterogeneous clusters are not supported. Hence it is easier to use nodesPattern to specify a number of same-region, same-flavor nodes.

If you want to use public networking, you're all set. If you want to use private networking, you'll also want to specify:

  • networkId: The ID of the vRack you want to use
  • subnetId: The ID of the vRack subnet you want your cluster to be attached to

The call returns an object describing the cluster you asked for. Initially, its status property will be CREATING. Take note of the id property of the newly-created cluster for the next step.

Step 3: Wait for your database service to be ready

The cluster will take a few minutes to become fully usable. You can check its status using:

The call returns an object describing the cluster. Its status property will transition to READY when the cluster becomes available.

Step 4: Whitelist the IP addresses or blocks you want to access your cluster from

For security reasons the default network configuration doesn't allow any incoming connections. It is thus critical you whitelist the suitable IP addresses in order to successfully access your database.

Declare the IP address blocks allowed to connect to your cluster with:

  • description is a human-readable description or label for the IP block
  • ip is a string representing an IP block or network, using the syntax aaa.bbb.ccc.ddd/xy -- If you want to specify a single IP address, use aaa.bbb.ccc.ddd/32

You can add multiple allowed IP blocks.

Step 5: Reset the primary user password

At this point you don't know your cluster primary user's password. List your cluster's users with:

Note the id of your admin user. Reset its password with:

Note the new password of the user to later be able to connect to the cluster.

That password won't ever be available later on: OVHcloud never stores users' passwords.

Step 6: Start using the cluster

You’ll find the cluster connection information in your Control Panel; you can now start using the cluster!

Go further

MongoDB capabilities

Managing a MongoDB service from the OVHcloud Control Panel

Configuring vRack for Public Cloud

Visit our dedicated Discord channel: https://discord.gg/PwPqWUpN8G. Ask questions, provide feedback and interact directly with the team that builds our databases services.

Join our community of users on https://community.ovh.com/en/.


Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.


These guides might also interest you...

OVHcloud Community

Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Discuss with the OVHcloud community

In accordance with the 2006/112/CE Directive, modified on 01/01/2015, prices incl. VAT may vary according to the customer's country of residence
(by default, the prices displayed are inclusive of the UK VAT in force).