PSQL Error FATAL: password authentication failed for user "postgres"

Summary

I just created an Kubernetes Cluster, which is empty and nothing else is running inside.

I have currently this setup:

control-plane-1   Ready    control-plane,master   25h   v1.20.7
control-plane-2   Ready    control-plane,master   25h   v1.20.7
control-plane-3   Ready    control-plane,master   25h   v1.20.7
worker-node-1     Ready    <none>                 25h   v1.20.7
worker-node-2     Ready    <none>                 25h   v1.20.7
worker-node-3     Ready    <none>                 25h   v1.20.7

The helm version which is currently on my local machine installed is:

helm version                                     
version.BuildInfo{Version:"v3.5.4", GitCommit:"1b5edb69df3d3a08df77c9902dc17af864ff05d1", GitTreeState:"dirty", GoVersion:"go1.16.3"}

When I'm installing gitlab as helm chart the most apps are starting, but I have an issue with the Postgres container, the container stops with the following message in his logs:

postgresql 11:06:33.92
postgresql 11:06:33.92 Welcome to the Bitnami postgresql container
postgresql 11:06:33.92 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
postgresql 11:06:33.92 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
postgresql 11:06:33.92
postgresql 11:06:33.97 INFO  ==> ** Starting PostgreSQL setup **
postgresql 11:06:33.98 INFO  ==> Validating settings in POSTGRESQL_* env vars..
postgresql 11:06:33.99 INFO  ==> Loading custom pre-init scripts...
postgresql 11:06:34.00 INFO  ==> Loading user's custom files from /docker-entrypoint-preinitdb.d ...
postgresql 11:06:34.01 INFO  ==> Initializing PostgreSQL database...
postgresql 11:06:34.07 INFO  ==> pg_hba.conf file not detected. Generating it...
postgresql 11:06:34.07 INFO  ==> Generating local authentication configuration
postgresql 11:06:34.08 INFO  ==> Deploying PostgreSQL with persisted data...
postgresql 11:06:34.21 INFO  ==> Configuring replication parameters
postgresql 11:06:34.28 INFO  ==> Configuring fsync
postgresql 11:06:34.37 INFO  ==> Loading custom scripts...
postgresql 11:06:34.37 INFO  ==> Loading user's custom files from /docker-entrypoint-initdb.d ...
postgresql 11:06:34.38 INFO  ==> Starting PostgreSQL in background...
psql: FATAL:  password authentication failed for user "postgres"
postgresql 11:06:34.97 INFO  ==> Stopping PostgreSQL...
waiting for server to shut down.... done
server stopped

Steps to reproduce

I just wrote an Ansible Playbook with the following tasks:

- name: Add a gitlab repository
  community.kubernetes.helm_repository:
    name: gitlab
    repo_url: https://charts.gitlab.io/

- name: Create a gitlab namespace
  community.kubernetes.k8s:
    name: gitlab
    api_version: v1
    kind: Namespace
    state: present

- name: Deploy latest version of gitlab chart
  community.kubernetes.helm:
    name: gitlab
    chart_ref: gitlab/gitlab
    namespace: gitlab
    values:
      global:
        edition: ce
        hosts:
          domain: domain.com
          externalIP: 1xx.2xx.7x.1xx
        psql:
          username: gitlab
          database: gitlabhq_production
          password:
            useSecret: true
            secret: gitlab-postgres
            key: postgresql-postgres-password
      certmanager-issuer:
        email: email@test.com
      postgresql:
        existingSecret: gitlab-postgres

These values should be mostly default as written in the documentation, but I don't know why the Postgres is stopping.

There was a similar error before, but the ticket status is on solved: #2345 (closed)

The configmap looks also as in the ticket described:

Name:         gitlab-postgresql-init-db
Namespace:    gitlab
Labels:       app=gitlab
              app.kubernetes.io/managed-by=Helm
              chart=gitlab-4.11.4
              heritage=Helm
              release=gitlab
Annotations:  meta.helm.sh/release-name: gitlab
              meta.helm.sh/release-namespace: gitlab

Data
====
init_revision.sh:
----
if [[ ! -f "$POSTGRESQL_VOLUME_DIR/.gitlab_1_scripts_initialized" ]] ; then
  rm -f "$POSTGRESQL_VOLUME_DIR/.user_scripts_initialized"
  touch "$POSTGRESQL_VOLUME_DIR/.gitlab_1_scripts_initialized"
fi

enable_extensions.sh:
----
[[ -n "${POSTGRES_POSTGRES_PASSWORD_FILE:-}" ]] && POSTGRES_POSTGRES_PASSWORD=$(cat ${POSTGRES_POSTGRES_PASSWORD_FILE})
PGPASSWORD=${POSTGRES_POSTGRES_PASSWORD} psql -d gitlabhq_production -U postgres -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS btree_gist;'

Events:  <none>

Versions

  • Chart: 4.11.4
  • Platform:
    • Self-hosted Machine
  • Kubernetes: (kubectl version)
    • Client: v1.21.0
    • Server: v1.20.7
  • Helm: (helm version)
    • Client: v3.5.4