How To change noobaa PostgreSQL password in Kubernetes - noobaa/noobaa-core GitHub Wiki

Steps

  1. Stop noobaa-operator pod from running

    kubectl scale deployment noobaa-operator --replicas 0
    
  2. Stop noobaa-core and noobaa-endpoint

    kubectl scale statefulset noobaa-core --replicas 0
    kubectl scale deployment noobaa-endpoint --replicas 0
    
  3. Go into noobaa-db-pg-0 pod and change the password for user noobaa in psql

    kubectl exec -it noobaa-db-pg-0 -- bash
    psql -d nbcore
    ALTER USER noobaa WITH PASSWORD 'myNewPassword';
    
  4. Change the password in noobaa-db secret which holds the Postgres credentials for all other pods.
    the best way to do that is to add stringData object to the secret. The values in stringData will be encoded as base64 automatically

    k edit secrets noobaa-db
    

    e.g.

    # Please edit the object below. Lines beginning with a '#' will be ignored,
    # and an empty file will abort the edit. If an error occurs while saving this file will be
    # reopened with the relevant failures.
    #
    apiVersion: v1
    data:
      password: YmxhYmxh
      user: bm9vYmFh
    
    stringData: # <<<===== add stringData
      password: "myNewPassword" # <<<===== write new password as string (not base64)
    
    kind: Secret
    metadata:
      creationTimestamp: "2022-01-16T08:39:57Z"
      labels:
        app: noobaa
      name: noobaa-db
      namespace: test-58
      ownerReferences:
      - apiVersion: noobaa.io/v1alpha1
        blockOwnerDeletion: true
        controller: true
        kind: NooBaa
        name: noobaa
        uid: 0e313a83-7a0e-43d6-94b0-a7a12845ee5e
      resourceVersion: "45172"
      uid: 57c09bb0-8f31-4c29-9f84-933cb46f9d78
    type: Opaque
    

    after saving this should look like this:

    apiVersion: v1
    data:
      password: bXlOZXdQYXNzd29yZA==  # <<<==== new password in base64
      user: bm9vYmFh
    kind: Secret
    metadata:
      creationTimestamp: "2022-01-16T08:39:57Z"
      labels:
        app: noobaa
      name: noobaa-db
      namespace: test-58
      ownerReferences:
      - apiVersion: noobaa.io/v1alpha1
        blockOwnerDeletion: true
        controller: true
        kind: NooBaa
        name: noobaa
        uid: 0e313a83-7a0e-43d6-94b0-a7a12845ee5e
      resourceVersion: "45804"
      uid: 57c09bb0-8f31-4c29-9f84-933cb46f9d78
    type: Opaque
    
  5. Restart all pods

    kubectl scale deployment noobaa-endpoint --replicas 1
    kubectl scale statefulset noobaa-core --replicas 1
    kubectl scale deployment noobaa-operator --replicas 1