k8s-config-connector: Root password not set on postgres instance

Describe the bug I’m creating an SQLInstance of type POSTGRES_12. As rootPassword I pass a secret key reference which contains the desired password for the root (postgres) user. The instance is created successfully and my expectation is that I can connect to it with the user postgres and the password I defined in the secret. However, my connection failed with the reason “wrong password”.

After setting the password over the following gcloud command, the connection works:

gcloud sql users set-password postgres --prompt-for-password --instance=test

I even tried to define a resource of type SQLUser with name postgres, but no luck either.

ConfigConnector Version 1.21.1

To Reproduce Apply the manifest below.

YAML snippets:

---
apiVersion: sql.cnrm.cloud.google.com/v1beta1
kind: SQLInstance
metadata:
  name: test
  namespace: test
spec:
  databaseVersion: POSTGRES_12
  region: europe-west6
  settings:
    activationPolicy: ALWAYS
    availabilityType: ZONAL
    diskAutoresize: true
    diskSize: 10
    diskType: PD_HDD
    ipConfiguration:
      ipv4Enabled: false
      privateNetworkRef:
        external: projects/ufg-demo/global/networks/default
      requireSsl: false
    tier: db-f1-micro
  rootPassword:
    valueFrom:
      secretKeyRef:
        name: test-credentials
        key: password
---
apiVersion: v1
kind: Secret
metadata:
  name: test-credentials
  namespace: test
stringData:
  password: some-password

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@mruoss, we will keep investigating why the default user cannot be updated by ConfigConnector. Thanks for your detailed information.

Hey @tonybenchsci, I opened a new thread (#292) about your issue given that it’s kind of its own topic. Let us continue the conversation there.

@caieo @maqiuyujoyce We have a related issue and probably same root cause as this. We suspect it has to do with the 1.19.0 update that did “Fix issue where SQLuser would constantly update despite there being no changes.”

I’m afraid we might have been using the constant update as a feature instead of a bug. We have a system where we rely on KCC’s reconciliation loop to rectify a SQLUser password (via a secretRef) after a restoring a sqlinstance from a backup (which overwrites credentials).

The expected behaviour is that each time the SQLUser resource is “up-to-date”, then the password should be whatever is specified in secretRef. But we see “up-to-date” but the password is not changed.

Hi @xiaobaitusi I faced another issue. Apparently the user created with SQLUser is not a SUPERUSER like the postgres user. So it is not equivalent to the postgres user and I am stuck again…

Hi @mruoss , it looks like the field rootPassword is ignored for PostgreSQL. Unfortunately, our public documentation is lacking definitions for the fields, but if you look at the CRD, the field has this description: Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL. We’ll work on making that more clear in the future.

I also tried having a SQLUser as postgres to access the SQLInstance, but it did not work, so we will investigate further.