# Adding custom user to repsets psmdb

**URL:** <https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852>\
**Category:** Percona Operator for MongoDB\
**Tags:** percona, mongodb, psmdb-operator\
**Created:** [February 21, 2025, 2:42pm UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852 "2025-02-21T14:42:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Smearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/henry_smearman/32/18339_2.png) [@Henry\_Smearman](https://forums.percona.com/u/Henry_Smearman)\
**Post date:** [February 21, 2025, 2:42pm UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852/1 "2025-02-21T14:42:36Z")

</div>

I am trying to add a custom user to mongoDB database. I am not using sharding only using repsets. Can this be done ? Below is a snippet from my values file. So far I have no luck. Thanks for any insight. ( my spacing is ok, I cant get it to paste correctly)

replsets:  
rs0:  
name: rs0  
size: 3  
users:  
- name: my-user  
db: admin  
passwordSecretRef:  
# name: my-user-password  
# key: password  
roles:  
- name: clusterAdmin  
db: admin  
- name: userAdminAnyDatabase  
db: admin

---

<div class="post-metadata">

**Author:** ![eleonora.zinchenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/eleonora.zinchenko/32/19132_2.png) [@eleonora.zinchenko](https://forums.percona.com/u/eleonora.zinchenko)\
**Post date:** [February 24, 2025, 9:18am UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852/2 "2025-02-24T09:18:18Z")

</div>

Hi,

Could you describe the issue you are facing in more detail? Are you getting some errors in logs/when applying `cr.yaml`?  
From the provided config part the suspicious part is that `passwordSecretRef ` values are commented out. On 1.18.0 and before the `passwordSecretRef ` is mandatory, on 1.19.0+ it can be skipped, in which case operator generates secret and password. The examples are available n documentation at [link](https://docs.percona.com/percona-operator-for-mongodb/users.html?h=custom+users#create-users-in-the-custom-resource) .

---

<div class="post-metadata">

**Author:** ![Henry\_Smearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/henry_smearman/32/18339_2.png) [@Henry\_Smearman](https://forums.percona.com/u/Henry_Smearman)\
**Post date:** [February 24, 2025, 3:15pm UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852/3 "2025-02-24T15:15:02Z")

</div>

Hi  
Thanks for your reply. My issue is the user is not being added. My first attempt was using the passwordSecretRef but noticed that 1.19 the operator will create the password for you. So I commented out the REF just in case my error was in my secert but still no user is created. Im only using the repset, sharding is disabled. Are users allowed to be added to the repset section ?

---

<div class="post-metadata">

**Author:** ![Henry\_Smearman](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/henry_smearman/32/18339_2.png) [@Henry\_Smearman](https://forums.percona.com/u/Henry_Smearman)\
**Post date:** [February 24, 2025, 4:06pm UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852/4 "2025-02-24T16:06:15Z")

</div>

Hi  
I got it working. I was defining the user under the replica set definitions and not at the root level. I was able to get the user added. thanks for you help!

---

<div class="post-metadata">

**Author:** ![eleonora.zinchenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/eleonora.zinchenko/32/19132_2.png) [@eleonora.zinchenko](https://forums.percona.com/u/eleonora.zinchenko)\
**Post date:** [February 24, 2025, 4:31pm UTC](https://forums.percona.com/t/adding-custom-user-to-repsets-psmdb/36852/5 "2025-02-24T16:31:11Z")

</div>

Hi!

Glad to hear that you made it work! Feel free to ask if other questions come up. 🙂
