Running non-sharding setup with only 1 replica

Hello

May be I missed that but is it possible to run the “non-sharding” setup with only one replica ?

[edit] … and what is the absolute minimum, so that a cluster is responsive, even if a replica would be down (for ex due to GKE nightly maintenance) ?

Regards
John

hey John,

May be I missed that but is it possible to run the “non-sharding” setup with only one replica ?

Did you mean single-member replicaSet? Then yes. For the normal setup, to convert a standalone, you will need to add the below configuration to mongod.conf file and restart:

replication:
  replSetName: "rs0"

Then initiate the replicaset as follows:

rs.initiate()

.
For the psmdb operator, keep spec.sharding.enabled: false and spec.replsets.size: 1 in cr.yaml. See here and here.
From my test:

$ kubectl get pods -n psmdb 
NAME                                               READY   STATUS    RESTARTS      AGE
my-cluster-name-rs0-0                              2/2     Running   5 (24h ago)   33h
percona-server-mongodb-operator-85779f9cd7-6xklq   1/1     Running   6 (24h ago)   6d23h

From the values of cr.yaml:

$ kubectl get psmdb -n psmdb -o=jsonpath='{.items[0].spec.replsets[].size}' 
1
$ kubectl get psmdb -n psmdb -o=jsonpath='{.items[0].spec.sharding.enabled}' 
false

.

[edit] … and what is the absolute minimum, so that a cluster is responsive, even if a replica would be down (for ex due to GKE nightly maintenance) ?

Can you explain this clearly? In the above statement, you mentioned non-sharding and here you are asking about the sharded cluster stability when a replica is down. If you are asking about fault tolerance of a replicaset, then refer here. Else if you could explain the architecture and your end goal clearly, then we may try to help you with that direction.

Regards,
Vinodh Guruji

To add more to what @Vinodh_Krishnaswamy said, you might also need to disable unsafe flag (if you use old version, otherwise operator will scale it up to 3 automatically).

Read more about unsafe flag here: Custom Resource options - Percona Operator for MongoDB

Also feel free to book me here: Zoom Scheduler
if you want to chat about it and open to share your use cases :slight_smile: