#

                    %                        _____
                   %%%                      |  __ \
                 ###%%%%%%%%%%%%*           | |__) |__ _ __ ___ ___  _ __   __ _
                ###  ##%%      %%%%         |  ___/ _ \ '__/ __/ _ \| '_ \ / _` |
              ####     ##%       %%%%       | |  |  __/ | | (_| (_) | | | | (_| |
             ###        ####      %%%       |_|   \___|_|  \___\___/|_| |_|\__,_|
           ,((###         ###     %%%        _      _          _____                       _
          (((( (###        ####  %%%%       | |   / _ \       / ____|                     | |
         (((     ((#         ######         | | _| (_) |___  | (___   __ _ _   _  __ _  __| |
       ((((       (((#        ####          | |/ /> _ </ __|  \___ \ / _` | | | |/ _` |/ _` |
      /((          ,(((        *###         |   <| (_) \__ \  ____) | (_| | |_| | (_| | (_| |
    ////             (((         ####       |_|\_\\___/|___/ |_____/ \__, |\__,_|\__,_|\__,_|
   ///                ((((        ####                                  | |
 /////////////(((((((((((((((((########                                 |_|   Join @ percona.com/k8s


Join Percona Squad! Get early access to new product features, invite-only ”ask me anything” sessions with Percona Kubernetes experts, and monthly swag raffles.

>>> https://percona.com/k8s <<<

To get a PostgreSQL prompt inside your new cluster you can run:
{{ $clusterName := include "pg-database.fullname" . }} 
{{- if .Values.users }}
  {{ $users := .Values.users }} {{ $firstUser := first $users }} {{ $userName := $firstUser.name }}
  PGBOUNCER_URI=$(kubectl -n {{ .Release.Namespace }} get secrets {{ $clusterName }}-pguser-{{ $userName }} -o jsonpath="{.data.pgbouncer-uri}" | base64 --decode)
{{- else }}
  PGBOUNCER_URI=$(kubectl -n {{ .Release.Namespace }} get secrets {{ $clusterName }}-pguser-{{ $clusterName }} -o jsonpath="{.data.pgbouncer-uri}" | base64 --decode)
{{- end }}

And then connect to a cluster with a temporary Pod:

  $ kubectl run -i --rm --tty percona-client --image=docker.io/percona/percona-distribution-postgresql:17.7-1 --restart=Never \
  -- psql $PGBOUNCER_URI
