- Deploy and Configure MongoDB Database Resources >
- Edit a Database Resource >
- Scale a Deployment
Scale a Deployment¶
On this page
You can scale your replica set and sharded cluster deployments up or down to match your desired configuration. Scaling up increases the number of members and/or shards in the deployment, thereby improving your deployment’s redundancy and availability. The scale of your deployment is configured in its corresponding custom resource.
- Scale a Replica Set
- To scale your replica set deployment, set the
spec.members
setting to the desired number of replica set members. To learn more about replication, see Replication in the MongoDB manual. - Scale a Sharded Cluster
To scale your sharded cluster deployment, set the following settings as desired:
Setting Description spec.shardCount
Number of shards in the sharded cluster. spec.mongodsPerShardCount
Number of members per shard. spec.mongosCount
Number of Shard Routers. spec.configServerCount
Number of members in the Config Server. To learn more about sharded cluster configurations, see Sharded Cluster Components in the MongoDB manual.
Considerations¶
The Kubernetes Operator does not support modifying deployment types. For example, you cannot convert a standalone deployment to a replica set. To modify the type of a deployment, we recommend the following procedure:
- Create the new deployment with the desired configuration.
- Back up the data from your current deployment.
- Restore the data from your current deployment to the new deployment.
- Test your application connections to the new deployment as needed.
- Once you have verified that the new deployment contains the required data and can be reached by your application(s), bring down the old deployment.
For MongoDB 4.4 deployments using MongoDB Enterprise Kubernetes Operator v1.7.0 and earlier, you can increase or decrease the number of members in a replica set or a sharded cluster by only one member at a time.
Example
To scale a replica set from three members to five members, you must:
- Change the value of the
spec.members
setting from3
to4
. - Reapply the configuration to Kubernetes.
- Change the value of the
spec.members
setting from4
to5
. - Reapply the configuration to Kubernetes.
- Change the value of the
Examples¶
Select the desired tab based on the deployment configuration you want to scale:
- Replica Set
- Sharded Cluster
Consider a replica set resource with the following custom resource:
To scale up this replica set and add more members:
Adjust the
spec.members
setting to the desired number of members:Important
For MongoDB 4.4 deployments using MongoDB Enterprise Kubernetes Operator v1.7.0 and earlier, you can increase or decrease the number of members in a replica set by only one member at a time.
Reapply the configuration to Kubernetes:
Consider a sharded cluster resource with the following custom resource:
To scale up this sharded cluster:
Adjust the following settings to the desired values:
Important
For MongoDB 4.4 deployments, you can increase or decrease the number of members in a sharded cluster by only one member at a time.
Reapply the configuration to Kubernetes: