|
| 1 | +================== |
| 2 | +Scale a Deployment |
| 3 | +================== |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +You can scale your :term:`replica set` and :term:`sharded cluster` |
| 14 | +deployments up or down to match your desired configuration. Scaling up |
| 15 | +increases the number of members and/or shards in the deployment, |
| 16 | +thereby improving your deployment's redundancy and availability. The |
| 17 | +scale of your deployment is configured in its corresponding |
| 18 | +|k8s-custom-resource|. |
| 19 | + |
| 20 | +Scale a Replica Set |
| 21 | + To scale your replica set deployment, set the :setting:`spec.members` |
| 22 | + setting to the desired number of replica set members. To learn more |
| 23 | + about replication, see :manual:`Replication </replication/>` in the |
| 24 | + MongoDB manual. |
| 25 | + |
| 26 | +Scale a Sharded Cluster |
| 27 | + To scale your sharded cluster deployment, set the following settings |
| 28 | + as desired: |
| 29 | + |
| 30 | + .. list-table:: |
| 31 | + :header-rows: 1 |
| 32 | + :widths: 20 40 |
| 33 | + |
| 34 | + * - Setting |
| 35 | + - Description |
| 36 | + |
| 37 | + * - :setting:`spec.shardCount` |
| 38 | + - Number of :term:`shards <shard>` in the sharded cluster. |
| 39 | + |
| 40 | + * - :setting:`spec.mongodsPerShardCount` |
| 41 | + - Number of members per shard. |
| 42 | + |
| 43 | + * - :setting:`spec.mongosCount` |
| 44 | + - Number of Shard Routers. |
| 45 | + |
| 46 | + * - :setting:`spec.configServerCount` |
| 47 | + - Number of members in the Config Server. |
| 48 | + |
| 49 | + To learn more about sharded cluster configurations, see |
| 50 | + :manual:`Sharded Cluster Components |
| 51 | + </core/sharded-cluster-components/>` in the MongoDB manual. |
| 52 | + |
| 53 | +Considerations |
| 54 | +-------------- |
| 55 | + |
| 56 | +The |k8s-op-short| does not support modifying deployment types. |
| 57 | +For example, you cannot convert a standalone deployment to a |
| 58 | +replica set. To modify the type of a deployment, |
| 59 | +we recommend the following procedure: |
| 60 | + |
| 61 | +1. Create the new deployment with the desired configuration. |
| 62 | + |
| 63 | +#. :opsmgr:`Back up the data </tutorial/nav/backup-deployments/>` from |
| 64 | + your current deployment. |
| 65 | + |
| 66 | +#. :opsmgr:`Restore the data |
| 67 | + </tutorial/nav/backup-restore-deployments/>` from your current |
| 68 | + deployment to the new deployment. |
| 69 | + |
| 70 | +#. Test your application connections to the new deployment as needed. |
| 71 | + |
| 72 | +#. Once you have verified that the new deployment contains the |
| 73 | + required data and can be reached by your application(s), bring |
| 74 | + down the old deployment. |
| 75 | + |
| 76 | +Examples |
| 77 | +-------- |
| 78 | + |
| 79 | +Select the desired tab based on the deployment configuration you |
| 80 | +want to scale: |
| 81 | + |
| 82 | +.. tabs-deployments:: |
| 83 | + |
| 84 | + .. tab:: |
| 85 | + :tabid: repl |
| 86 | + |
| 87 | + Consider a replica set resource with the following |
| 88 | + |k8s-custom-resource|: |
| 89 | + |
| 90 | + .. literalinclude:: /reference/k8s/example-replica-set-minimal.yaml |
| 91 | + :language: yaml |
| 92 | + :emphasize-lines: 9 |
| 93 | + |
| 94 | + To scale up this replica set and add more members: |
| 95 | + |
| 96 | + 1. Adjust the :setting:`spec.members` setting to the desired |
| 97 | + number of members: |
| 98 | + |
| 99 | + .. literalinclude:: /reference/k8s/example-replica-set-minimal-scaled.yaml |
| 100 | + :language: yaml |
| 101 | + :emphasize-lines: 9 |
| 102 | + |
| 103 | + #. Reapply the configuration to |k8s|: |
| 104 | + |
| 105 | + .. code-block:: none |
| 106 | + |
| 107 | + kubectl apply -f <repl-set-config>.yaml |
| 108 | + |
| 109 | + .. tab:: |
| 110 | + :tabid: shard |
| 111 | + |
| 112 | + Consider a sharded cluster resource with the following |
| 113 | + |k8s-custom-resource|: |
| 114 | + |
| 115 | + .. literalinclude:: /reference/k8s/example-sharded-cluster-minimal.yaml |
| 116 | + :language: yaml |
| 117 | + :emphasize-lines: 9-12 |
| 118 | + |
| 119 | + To scale up this sharded cluster: |
| 120 | + |
| 121 | + 1. Adjust the following settings to the desired values: |
| 122 | + |
| 123 | + - :setting:`spec.shardCount` |
| 124 | + - :setting:`spec.mongodsPerShardCount` |
| 125 | + - :setting:`spec.mongosCount` |
| 126 | + - :setting:`spec.configServerCount` |
| 127 | + |
| 128 | + .. literalinclude:: /reference/k8s/example-sharded-cluster-minimal-scaled.yaml |
| 129 | + :language: yaml |
| 130 | + :emphasize-lines: 9-12 |
| 131 | + |
| 132 | + #. Reapply the configuration to |k8s|: |
| 133 | + |
| 134 | + .. code-block:: none |
| 135 | + |
| 136 | + kubectl apply -f <sharded-cluster-config>.yaml |
0 commit comments