2

I have deployed mongodb sharded cluster in kubernetes. via: helm install my-release bitnami/mongodb-sharded with default features of 2 shards and only 1 replica per shard.

It is running fine but now I must increase the total number of shards to 4 and each shard replica to 3. Any idea how to do that?

Prata
  • 1,250
  • 2
  • 16
  • 31

3 Answers3

0

If I recall correctly you can make those changes using command line:

$ helm install my-release --set shards=4, configsvr.replicas=3 bitnami/mongodb-sharded

As for replicas it depends what exactly your want to scale, you can choose from following:

configsvr.replicas

Number of nodes in the replica set (the first node will be primary)

or

mongos.replicas

Number of Mongos nodes to create

or

shardsvr.dataNode.replicas

Number of nodes in each shard replica set (the first node will be primary)

or

shardsvr.arbiter.replicas

Number of arbiters in each shard replica set (the first node will be primary)

Everything is described in Installing the Chart

Crou
  • 10,232
  • 2
  • 26
  • 31
  • Yes, That is true for fresh installation but I want to upgrade my current mongodb deployment. – Prata Feb 17 '20 at 12:43
  • 1
    You should be looking at [`$ helm upgrade`](https://helm.sh/docs/helm/helm_upgrade/) – Crou Feb 17 '20 at 12:59
  • 1
    I'm working with this bitnami helm chart right now, for anyone who is looking. Make sure you set a string value in the values.yaml for the `replicaSetKey` property. I struggled for quite awhile with not understanding why when adding an extra shard at to the values.yaml and running helm upgrade wouldn't allow the new shard to connect to the cluster. It was because all shards in the cluster must have matching `replicaSetKey` (atleast in my instance). Read docs here: https://docs.mongodb.com/manual/tutorial/deploy-sharded-cluster-with-keyfile-access-control/ – Mike Kellogg Jun 03 '21 at 13:52
0

$ helm upgrade my-release -f values.yaml bitnami/mongodb-sharded.

You do the changes in values.yaml like shards, configsvr.replicas if have already deployed the chart with default configuration. You are done.

NOTE: you have to set mongodbRootPassword and replicaSetKey with the values obtained in the installation notes

Ajeet Sharma
  • 214
  • 2
  • 9
0

There is one field replicaSetKey which is not set by default in mongodb sharded values.yaml file. But when you upgrade you want that value in.

Solutions:

  1. Pass your meaningful string in .Vaules.replicaSetKey at the time of first deployment only and upgrade using the same values.yaml file.
  2. If you don't do that it will generate a random replicasetkey string initially which you have to get from secrets and pass that random generated string (base64 decoded) when upgrading.

I have also faced the same issue was not aware about replicaSetKey. Please refer issue