- Deploy Resources >
- Deploy a Replica Set
Deploy a Replica Set¶
On this page
Supported with Cloud Manager and Ops Manager 4.0
You can use Kubernetes Operator to deploy MongoDB instances with Ops Manager version 4.0 or later and Cloud Manager. At any place in this guide that says Ops Manager, you can substitute Cloud Manager.
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.
Use this procedure to deploy a new replica set that Ops Manager manages. After deployment, use Ops Manager to manage the replica set, including such operations as adding, removing, and reconfiguring members.
Prerequisites¶
To deploy a replica set using an object, you need to complete the following procedures:
Considerations¶
Starting in MongoDB Enterprise Kubernetes Operator version 1.3.0, you can only have one MongoDB resource per project. To learn how to migrate your project to a single-cluster configuration, see Migrate to One Resource per Project (Required for Version 1.3.0).
Procedure¶
Copy the highlighted section of this replica set resource.¶
Change the highlighted settings of this YAML file to match your desired replica set configuration.
Paste the copied example to create a new replica set resource.¶
Open your preferred text editor and paste the object specification into a new text file.
Change the highlighted settings to your preferred values.¶
Key | Type | Description | Example |
---|---|---|---|
metadata.name |
string | Label for this Kubernetes replica set object. See also
|
myproject |
metadata.namespace |
string | Scope of object names. Kubernetes namespace where this MongoDB Kubernetes resource and other objects are created. Using two different namespaces allows you to delete your standalone or all of the resources in the namespace without affecting your Kubernetes Operator. See also
|
mongodb |
spec.members |
integer | Number of members of the replica set. | 3 |
spec.version |
string | Version of MongoDB that this replica set should run. The format should be To learn more about MongoDB versioning, see MongoDB Versioning in the MongoDB Manual. |
3.6.7 |
string | Name of the ConfigMap with the Ops Manager connection
configuration. The
Value must match namespace and name of ConfigMap This value must match the value you provided for
If this MongoDB Kubernetes resource is in a different namespace than the
project ConfigMap, you should
set this value to the namespace and name of the
ConfigMap in this format:
Operator manages changes to the ConfigMap The Kubernetes Operator tracks any changes to the ConfigMap and reconciles the state of the MongoDB Kubernetes resource. |
<myconfigmap> |
|
spec.credentials |
string | Name of the Kubernetes secret you created as Ops Manager API authentication credentials for the Kubernetes Operator to communicate with Ops Manager. Value must use namespace and name of Secret This value must match the value you provided for
Operator manages changes to the Secret The Kubernetes Operator tracks any changes to the Secret and reconciles the state of the MongoDB Kubernetes resource. |
<mycredentials> |
spec.type |
string | Type of MongoDB Kubernetes resource to create. | ReplicaSet |
spec.persistent |
string | Optional. Flag indicating if this MongoDB Kubernetes resource should use Persistent Volumes for storage. Persistent volumes are not deleted when the MongoDB Kubernetes resource is stopped or restarted. If this value is To change your Persistent Volume Claims configuration, configure the following collections to meet your deployment requirements:
Warning Your containers must have permissions to write to your Persistent Volume.
The Kubernetes Operator sets Note If you do not use Persistent Volumes, the Disk Usage and Disk IOPS charts cannot be displayed in either the Processes tab on the Deployment page or in the Metrics page when reviewing the data for this deployment. |
true |
Add any additional accepted settings for a replica set deployment.¶
You can also add any of the following optional settings to the object specification file for a replica set deployment:
spec.clusterName
spec.featureCompatibilityVersion
spec.logLevel
spec.podSpec.cpu
spec.podSpec.cpuRequests
spec.podSpec.memory
spec.podSpec.memoryRequests
spec.podSpec.persistence.single
spec.podSpec.persistence.multiple.data
spec.podSpec.persistence.multiple.journal
spec.podSpec.persistence.multiple.logs
spec.podSpec.podAffinity
spec.podSpec.podAntiAffinityTopologyKey
spec.podSpec.nodeAffinity
Warning
You must set spec.clusterName
if your Kubernetes cluster has a
default domain
different from default cluster.local
. If you neither use the
default nor set this option, the Kubernetes Operator may not function as
expected.
Save this replica set config file with a .yaml
file extension.¶
Start your replica set deployment.¶
Invoke the following Kubernetes command to create your replica set:
Track the status of your replica set deployment.¶
To check the status of your MongoDB Kubernetes resource, invoke the following command:
The -w
flag means “watch”. With the “watch” flag set, the output
refreshes immediately when something changes until the status phase
achieves the Running
state.
See Troubleshooting the Kubernetes Operator for information about the resource deployment statuses.