percona-server-mongodb-operator icon indicating copy to clipboard operation
percona-server-mongodb-operator copied to clipboard

User Management trough operator - adding a new user

Open Juoper opened this issue 3 months ago • 4 comments

Report

I tried adding a new user to the cluster after the deployment. i added this section to the yaml, but nothing is changed and no logs from the operator:

    - db: backend
      name: backend-user
      roles:
        - db: backend
          name: dbAdmin
        - db: backend
          name: readWrite

More about the problem

nothing is happening

Steps to reproduce

  1. deploy cluster with users initially
  2. verify users are there
  3. add another user with it's own database

Versions

  1. Kubernetes v1.31.12+k3s1
  2. Operator psmdb-operator:1.20.1
  3. Database psmdb-db:1.20.1

Anything else?

No response

Juoper avatar Oct 16 '25 21:10 Juoper

Hi @Juoper I can't reproduce this issue :(

  1. I have created cluster:
❯ kubectl get pods
NAME                                               READY   STATUS    RESTARTS   AGE
my-cluster-name-cfg-0                              2/2     Running   0          2m15s
my-cluster-name-cfg-1                              2/2     Running   0          110s
my-cluster-name-cfg-2                              2/2     Running   0          85s
my-cluster-name-mongos-0                           1/1     Running   0          38s
my-cluster-name-mongos-1                           1/1     Running   0          26s
my-cluster-name-mongos-2                           1/1     Running   0          15s
my-cluster-name-rs0-0                              2/2     Running   0          2m14s
my-cluster-name-rs0-1                              2/2     Running   0          108s
my-cluster-name-rs0-2                              2/2     Running   0          82s
percona-server-mongodb-operator-64976cdb47-5hk8d   1/1     Running   0          13m
❯ kubectl get psmdb
NAME              ENDPOINT                                                 STATUS   AGE
my-cluster-name   my-cluster-name-mongos.default.svc.cluster.local:27017   ready    2m23s
  1. added user via CR
diff --git a/deploy/cr.yaml b/deploy/cr.yaml
index 073d5e471..5edb01fd0 100644
--- a/deploy/cr.yaml
+++ b/deploy/cr.yaml
@@ -600,26 +600,14 @@ spec:
 #          serverAddress:
 #            - 127.0.0.1

-#  users:
-#  - name: my-user
-#    db: admin
-#    passwordSecretRef:
-#      name: my-user-password
-#      key: my-user-password-key
-#    roles:
-#      - name: clusterAdmin
-#        db: admin
-#      - name: userAdminAnyDatabase
-#        db: admin
-#  - name: my-usr
-#    db: admin
-#    passwordSecretRef:
-#      name: my-user-pwd
-#      key: my-user-pwd-key
-#    roles:
-#      - name: dbOwner
-#        db: sometest
-
+  users:
+  - name: backend-user
+    db: backend
+    roles:
+      - name: dbAdmin
+        db: backend
+      - name: readWrite
+        db: backend
  1. The user and DB were created:
2025-10-23T09:33:11.088Z	INFO	Created custom user secrets	{"controller": "psmdb-controller", "controllerGroup": "psmdb.percona.com", "controllerKind": "PerconaServerMongoDB", "PerconaServerMongoDB": {"name":"my-cluster-name","namespace":"default"}, "namespace": "default", "name": "my-cluster-name", "reconcileID": "141ba537-e7bb-4ebd-8cef-1c2df3561243", "secrets": "my-cluster-name-custom-user-secret"}
2025-10-23T09:33:11.089Z	INFO	Creating user	{"controller": "psmdb-controller", "controllerGroup": "psmdb.percona.com", "controllerKind": "PerconaServerMongoDB", "PerconaServerMongoDB": {"name":"my-cluster-name","namespace":"default"}, "namespace": "default", "name": "my-cluster-name", "reconcileID": "141ba537-e7bb-4ebd-8cef-1c2df3561243", "user": "backend.backend-user"}
2025-10-23T09:33:11.127Z	INFO	User created	{"controller": "psmdb-controller", "controllerGroup": "psmdb.percona.com", "controllerKind": "PerconaServerMongoDB", "PerconaServerMongoDB": {"name":"my-cluster-name","namespace":"default"}, "namespace": "default", "name": "my-cluster-name", "reconcileID": "141ba537-e7bb-4ebd-8cef-1c2df3561243", "user": "backend.backend-user"}

hors avatar Oct 23 '25 09:10 hors

hello @Juoper, did you have the change to check @hors comment? Can you confirm that you are still facing this issue?

gkech avatar Oct 31 '25 09:10 gkech

Hey, sorry for the late response. For us the issue was, that we had created a new MongoDB Cluster with some users. then after some time in ready state we added another user to the users array and this one wasn't created

Juoper avatar Nov 04 '25 13:11 Juoper

Hey @Juoper, I attempted to reproduce this issue using the additional information you shared, but I wasn’t able to. Have you encountered this problem only once, or is it consistently reproducible on your end?

hors avatar Nov 14 '25 10:11 hors

@Juoper We haven’t heard from you in over a month, so we’ll close this issue for now. If the problem persists, please open a new issue and we’ll be glad to assist.

hors avatar Dec 19 '25 11:12 hors