Connecting to Postgres

Description:

Trying to connect to my Postgres database. Ideally, it’d be nice if port forwarding would allow me to connect to the service on localhost, but for now, just trying to stick to the instructions to get a basic shell.

I’m running on k3d and had the same issues on GCP

Steps to Reproduce:

  1. PGBOUNCER_URI=$(kubectl -n postrgers-operator get secrets dashboard-v2-6-0-pguser-grafana -o jsonpath=‘{.data.pgbouncer-uri}’ | base64 --decode)
  2. kubectl run -i --rm --tty pg-client --image=perconalab/percona-distribution-postgresql:16 --restart=Never – psql $PGBOUNCER_URI
psql: error: connection to server at "dashboard-v2-6-0-pgbouncer.postgres-operator.svc" (10.43.128.30), port 5432 failed: FATAL:  no such user
connection to server at "dashboard-v2-6-0-pgbouncer.postgres-operator.svc" (10.43.128.30), port 5432 failed: FATAL:  SSL required
pod "pg-client" deleted
pod default/pg-client terminated (Error)

echo $PGBOUNCER_URI

postgresql://grafana:secret@dashboard-v2-6-0-pgbouncer.postgres-operator.svc:5432/dashboard

Version:

2.6.0

Logs:

kubectl -n postgres-operator logs service/dashboard-v2-6-0-pgbouncer

s
2025-06-05 20:32:51.376 UTC [8] LOG S-0x5555556b5c70: dashboard/_crunchypgbouncer@10.43.233.47:5432 new connection to server (from 10.42.0.15:49436)
2025-06-05 20:32:51.400 UTC [8] LOG S-0x5555556b5c70: dashboard/_crunchypgbouncer@10.43.233.47:5432 SSL established: TLSv1.3/TLS_AES_256_GCM_SHA384/ECDH=prime256v1
2025-06-05 20:32:51.444 UTC [8] LOG C-0x55555569a7b0: dashboard/(nouser)@10.42.0.26:35552 login failed: db=dashboard
2025-06-05 20:32:51.444 UTC [8] LOG C-0x55555569a7b0: dashboard/(nouser)@10.42.0.26:35552 closing because: no such user (age=0s)
2025-06-05 20:32:51.444 UTC [8] LOG S-0x5555556b5c70: dashboard/_crunchypgbouncer@10.43.233.47:5432 closing because: client disconnect before everything was sent to the server (age=0s)
2025-06-05 20:32:51.444 UTC [8] WARNING C-0x55555569a7b0: dashboard/(nouser)@10.42.0.26:35552 pooler error: no such user

Expected Result:

An psql shell

Actual Result:

errors on user auth and/or SSL Issues?

Additional Information:

Hi, rule of thumb when you see multiple errors describing an unsucessful operation always refer to the 1st error and ignore the rest.

Are you attempting login using an existing ROLE with a preassigned password?

i.e.
FATAL: no such user

It turns out that my user was an admin and the pgboucer wasn’t letting me though. It seems admin are by default prevented from being able to connect to the pgboucer.

I had to set:

  1. pgBouncer.exposeSuperusers: true

I also made sure the postrgres user was created just in case.

spec:
  users:
    - name: postgres
    - name: {{ app_admin }}
      databases:
        - {{ database_name}}
      password:
        type: ASCII

I forget where in the docs that was called out but It’d be nice if it was mentioned here: 2 Connect to PostgreSQL - Percona Operator for PostgreSQL

Usually you start by creating an admin then figure your service accounts.