Configuring sharding with mongo psmdb

Hi all,
I am trying to configure sharding on my mongodb cluster. I plan to have two or three shards.
I have understand that I have to add more replicas in the replsets section as the number of shards that I need.
However , there is another parameters under the sharding section: sharding.configrs.size , what value should I put on it then ? what is it for ?
I post here part of my config , thanks for your answer :slight_smile:

lab-psmdb-db:
  enabled: true
  replsets:
    - name: rs0
      size: 3
      antiAffinityTopologyKey: "kubernetes.io/hostname"
      expose:
        enabled: false
        exposeType: ClusterIP
      podDisruptionBudget:
        maxUnavailable: 1
      arbiter:
        enabled: false
        size: 0
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      resources:
        requests:
          cpu: "500m"
          memory: 1G
      volumeSpec:
        pvc:
          resources:
            requests:
              storage: 5Gi
    - name: rs1
      size: 3
      antiAffinityTopologyKey: "kubernetes.io/hostname"
      expose:
        enabled: false
        exposeType: ClusterIP
      podDisruptionBudget:
        maxUnavailable: 1
      arbiter:
        enabled: false
        size: 0
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      resources:
        requests:
          cpu: "500m"
          memory: 1G
      volumeSpec:
        pvc:
          resources:
            requests:
              storage: 5Gi
  sharding:
    enabled: true
    configrs:
      size: 2
      antiAffinityTopologyKey: "kubernetes.io/hostname"
    configsvrReplSet:
      size: 3
    mongos:
      size: 2
      antiAffinityTopologyKey: "kubernetes.io/hostname"
1 Like

Hello @Mialy_Tatienne_RAJAO ,

your understanding is correct, if you need two shards - you need 2 replica sets in spec.replsets:

replsets:
  - name: rs0
    ...
  - name: rs1
    ...

As for sharding.configsvrReplSet - it is the section for [Config Servers] replica set (https://www.mongodb.com/docs/v5.0/core/sharded-cluster-config-servers/) - they hold metadata for your sharded cluster. mongos uses them to route queries.

I’m not sure what configrs is and where is it coming from in your snippet. We don’t have it.

Please let me know if it helps.

2 Likes

Thanks for your feedback, very clear :slight_smile:

2 Likes