Navigation

Deploy a Replica Set

A replica set is a group of MongoDB deployments that maintain the same data set. Replica sets provide redundancy and high availability and are the basis for all production deployments.

To learn more about replica sets, see the Replication Introduction in the MongoDB manual.

You can use the Atlas Open Service Broker to deploy a new replica set managed by Atlas. After deployment, use Atlas to manage monitoring, backups, and project configuration such as VPC peering or billing.

Prerequisites

You create Atlas replica sets by defining an object. To deploy a replica set using an Kubernetes object, you must first install the Atlas Open Service Broker.

Considerations

Atlas Public API

Atlas Open Service Broker uses the Create a Cluster endpoint of the Atlas Public API to deploy replica sets. Any requirements or limitations of the API also apply to the Atlas Open Service Broker.

Procedure

1

Create a resource definition for your replica set.

  1. Copy one of the following resource definition examples based on the scope of your service broker instance.

    If you registered the Atlas Open Service Broker instance as a cluster-scoped ClusterServiceBroker, select Cluster-scoped Instance. If you registered the Atlas Open Service Broker instance as a namespace-scoped ServiceBroker, select Namespace-scoped Instance.


    Copy the following YAML file, which you can modify to meet your desired configuration:

    apiVersion: servicecatalog.k8s.io/v1beta1
    kind: ServiceInstance
    metadata:
      name: <CLUSTER_NAME>
      namespace: <NAMESPACE>
    spec:
      clusterServiceClassExternalName: <CLOUD_SERVICE_PROVIDER_CLASS>
      clusterServicePlanExternalName: <INSTANCE_SIZE_PLAN>
      parameters:
        cluster:
          providerSettings:
            regionName: <ATLAS_REGION>
    

    Copy the following YAML file, which you can modify to meet your desired configuration:

    apiVersion: servicecatalog.k8s.io/v1beta1
    kind: ServiceInstance
    metadata:
      name: <CLUSTER_NAME>
      namespace: <NAMESPACE>
    spec:
      serviceClassExternalName: <CLOUD_SERVICE_PROVIDER_CLASS>
      servicePlanExternalName: <INSTANCE_SIZE_PLAN>
      parameters:
        cluster:
          providerSettings:
            regionName: <ATLAS_REGION>
    
  2. Open your preferred text editor and paste the resource definition into a new text file.

2

Configure the required settings.

The highlighted settings are required to deploy a replica set:

Key Description Example
metadata.name The name of the cluster in Kubernetes. Atlas randomly generates a corresponding replica set name. my-atlas-cluster
metadata.namespace The Kubernetes namespace where this cluster is created. atlas
spec.clusterServiceClassExternalName

The Kubernetes class which corresponds to your Atlas cloud service provider.

View the available classes by invoking the following command:

svcat marketplace

The class names are listed in the CLASS column of the command output.

mongodb-atlas-aws
spec.clusterServicePlanExternalName

The Kubernetes service plan which corresponds to the desired Atlas instance size.

View the available plans by invoking the following command:

svcat marketplace

The plan names are listed in the PLANS column of the command output.

M10
spec.regionName

The Atlas region where the replica set is created.

Important

Make sure you use the Atlas region name for the desired region, not the cloud provider region name.

For a list of available regions, see the Atlas documentation for your cloud service provider:

EU_CENTRAL_1
Key Description Example
metadata.name The name of the cluster in Kubernetes. Atlas randomly generates a corresponding replica set name. my-atlas-cluster
metadata.namespace The Kubernetes namespace where this cluster is created. atlas
spec.serviceClassExternalName

The Kubernetes class which corresponds to your Atlas cloud service provider.

View the available classes by invoking the following command:

svcat marketplace

The class names are listed in the CLASS column of the command output.

mongodb-atlas-aws
spec.servicePlanExternalName

The Kubernetes service plan which corresponds to the desired Atlas instance size.

View the available plans by invoking the following command:

svcat marketplace

The plan names are listed in the PLANS column of the command output.

M10
spec.regionName

The Atlas region where the replica set is created.

Important

Make sure you use the Atlas region name for the desired region, not the cloud provider region name.

For a list of available regions, see the Atlas documentation for your cloud service provider:

EU_CENTRAL_1
3

(Optional) Configure any additional settings for a replica set deployment.

You can specify additional cluster settings under the spec.parameters.cluster key. These settings correspond to the request body parameters of the Create a Cluster Public API method.

Important

The following API parameters are overwritten by the required Atlas Open Service Broker settings from the previous step and should not be specified:

  • providerSettings.instanceSizeName
  • providerSettings.providerName
  • name

Example

This example resource definition creates a cluster called my-atlas-cluster in the atlas namespace that has the following configuration:

  • Managed by a cluster-scoped (ClusterServiceBroker) Atlas Open Service Broker
  • AWS as a cloud service provider
  • An instance size of M10
  • Located in the EU (Frankfurt) region
  • Auto-scaling disabled
  • Atlas continuous backups enabled
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
  name: my-atlas-cluster
  namespace: atlas
spec:
  clusterServiceClassExternalName: mongodb-atlas-aws
  clusterServicePlanExternalName: M10
  parameters:
    cluster:
      providerSettings:
        regionName: EU_CENTRAL_1
      autoscaling:
        diskGBEnabled: false
      backupEnabled: true

Example

This example resource definition creates a cluster called my-atlas-cluster in the atlas namespace that has the following configuration:

  • Managed by a namespace-scoped (ServiceBroker) Atlas Open Service Broker
  • AWS as a cloud service provider
  • An instance size of M10
  • Located in the EU (Frankfurt) region
  • Auto-scaling disabled
  • Atlas continuous backups enabled
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceInstance
metadata:
  name: my-atlas-cluster
  namespace: atlas
spec:
  serviceClassExternalName: mongodb-atlas-aws
  servicePlanExternalName: M10
  parameters:
    cluster:
      providerSettings:
        regionName: EU_CENTRAL_1
      autoscaling:
        diskGBEnabled: false
      backupEnabled: true
4

Save the file as replica-set.yaml.

5

Deploy the replica set.

Invoke the following Kubernetes command to create your replica set:

kubectl apply -f replica-set.yaml
6

Track the status of your replica set deployment.

To view the status of your deployment, pass the metadata.name from replica-set.yaml into the following command:

svcat describe instance <METADATA.NAME> -n <NAMESPACE>

As the replica set is being deployed, the command returns the following status:

Provisioning - The instance is being provisioned asynchronously

Once the replica set deploys successfully, the command returns the following status:

Ready - The instance was provisioned successfully